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 1 commit
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
73 changes: 69 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
🚀 Give your DSA journey a proper guide using pathways in our application.

## 🛠 Tech Used
- Python
- Django
- Django REST Framework
- Python3
- Django-3.1.5
- Django REST Framework-3.12.2

## 💫 Quick Start

Expand Down Expand Up @@ -55,6 +55,71 @@ 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
| |
| └──__pychache__ # Cache Folder [Default]
| ├──__init__.py # [Default]
| ├──asgi.py # [Default]
| ├──local_settings.py # [local file]
| ├──settings.py # [Default]
| ├──urls.py # [Default]
| └──wsgi.py
...
...
...
```

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 +133,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