Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solved issue regarding local_settings.py file not found #30

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 16 additions & 37 deletions AlgoPhantomBackend/AlgoPhantomBackend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,9 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*qh6y)st__^hvam8a@6ln5vz4+#_9qu$xl80oz%h9e71+-iutd'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
Expand All @@ -38,15 +28,18 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core.apps.CoreConfig',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'django.contrib.sites',

'allauth',
'allauth.account',
'allauth.socialaccount',

'rest_framework',
'rest_framework.authtoken',
'rest_auth.registration',
'rest_auth',

'core.apps.CoreConfig',
'quiz',
]

Expand Down Expand Up @@ -86,13 +79,6 @@
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -132,15 +118,6 @@

STATIC_URL = '/static/'

ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_AUTHENTICATION_METHOD = 'username'
ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
#ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS = False
#AUTH_USER_MODEL = 'core.User'


REST_AUTH_SERIALIZERS = {
'TOKEN_SERIALIZER': 'core.serializers.TokenSerializer',
'USER_DETAILS_SERIALIZER': 'core.serializers.UserSerializer',
Expand All @@ -158,10 +135,12 @@
],
}

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = EMAIL_HOST_PASSWORD
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_AUTHENTICATION_METHOD = 'username'
ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
#ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS = False
#AUTH_USER_MODEL = 'core.User'

DATA_UPLOAD_MAX_NUMBER_FIELDS = 10240
3 changes: 1 addition & 2 deletions AlgoPhantomBackend/AlgoPhantomBackend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""
from django.contrib import admin
from django.urls import path, include
from rest_auth.registration.views import VerifyEmailView, RegisterView, LoginView
from django.conf.urls import url
from rest_auth.registration.views import VerifyEmailView, RegisterView, LoginView

urlpatterns = [
path('admin/', admin.site.urls),
Expand All @@ -31,5 +31,4 @@
path('rest-auth/registration/', RegisterView.as_view(), name='account_signup'),
path('rest-auth/account-confirm-email/', VerifyEmailView.as_view(),name='account_email_verification_sent'),
url('rest-auth/account-confirm-email/(?P<key>[-:\w]+)/$', VerifyEmailView.as_view(),name='account_confirm_email'),

]
3 changes: 1 addition & 2 deletions AlgoPhantomBackend/core/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.shortcuts import render, redirect, HttpResponse, get_object_or_404
from django.http import HttpResponseBadRequest, JsonResponse,HttpResponseRedirect
from django.contrib.auth.models import User
# Create your views here.

def home(request):

def home(request):
return HttpResponse('Hello')

19 changes: 8 additions & 11 deletions AlgoPhantomBackend/quiz/models.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
from django.db import models
# Create your models here.


QUESTION_LEVEL = (
("Easy","Easy"),
("Medium","Medium"),
("Hard","Hard"),
("Easy", "Easy"),
("Medium", "Medium"),
("Hard", "Hard"),
)


class Category(models.Model):

name=models.CharField(max_length=255)
name = models.CharField(max_length=255)

def __str__(self):
return self.name

class Meta:
verbose_name= "Category"
verbose_name_plural= "Categories"
ordering=['id']
verbose_name = "Category"
verbose_name_plural = "Categories"
ordering = ['id']

class Quizzes(models.Model):

Expand Down Expand Up @@ -66,5 +65,3 @@ class Meta:
verbose_name_plural= "Answers"
ordering=['id']



70 changes: 66 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
🚀 Give your DSA journey a proper guide using pathways in our application.

## 🛠 Tech Used
- Python
- Django
- Django REST Framework

<img alt="Python" src="https://img.shields.io/badge/python%20-%2314354C.svg?&style=for-the-badge&logo=python&logoColor=white"/> <img alt="Django" src="https://img.shields.io/badge/django%20-%23092E20.svg?&style=for-the-badge&logo=django&logoColor=white"/> <img alt="Django Rest Framework" src="https://img.shields.io/badge/django rest framework%20-%23092E20.svg?&style=for-the-badge&logo=django&logoColor=white"/>

## 💫 Quick Start

Expand Down Expand Up @@ -55,6 +54,69 @@ python3 -m pip install -r requirements.txt
```
cd AlgoPhantomBackend
```

- *STEPS TO CREATE YOUR OWN local_settings.py file*

local_settings.py is not present in github repo as it contains important credentials regarding project which should not be shared publicly.


1. Create new file named as local_settings.py just beside settings.py file in
same folder.
Now your project structure will look like


```
ALGO-PHANTOMS-BACKEND # Project Name
|
├───AlgoPhantomBackend # Project Directory
| |
| .
| .
| ├──local_settings.py # [Created]
. .
. .
.
.
.
```

2. Copy paste this in local_settings.py file and change it accordingly.

```
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = 'any 50 digits long unique key with numbers alphabets symbols. anything'

DEBUG = True

ALLOWED_HOSTS = ['*']

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = "Put your email id here"
EMAIL_HOST_PASSWORD = "put your email app password generated here."
```

3. Dont know how to generate app password for email. check out this blog and set it up accordingly. DO NOT SHARE IT WITH ANYONE.
#### https://support.google.com/accounts/answer/185833?hl=en

4. If you are not able to setup this EMAIL_HOST_PASSWORD you can comment that for
testing purpose. But knowing how to do this is very useful in order to send
automated emails via contact form or for accont creation and all related stuff

*Any sensitive settings which you dont want to share can be put in local_settings.py file*

- Make migrations using-
```
python manage.py makemigrations
Expand All @@ -68,7 +130,7 @@ python3 manage.py makemigrations
```
python manage.py migrate
```
- Create a superuser-
- Create a superuser and put relevant details when prompted-
```
python manage.py createsuperuser
```
Expand Down