STAY INFORMED
following content serves as a personal note and may lack complete accuracy or
certainty.
Minimal-Mistakes instruction
Useful vscode Shortcut Keys
Unix Commands
npm Commands
Vim Commands
Git Note
Useful Figma Shortcut Keys
Django Deploy
Prepare to Deploy
Before you deploy, you must turn off debug mode. Otherwise, it leads to security issues.
Go to settings.py and change DEBUG = True to False and add your deploy website to in ALLOWED_HOSTS.
DEBUG = False
ALLOWED_HOSTS = ['.pythonanywhere.com']
Lastly, all static files should be in one directory. Add this line at very bottom in setting.py
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
And write
python manage.py collectstatic
Deploy(pythonanywhere)
-
zip your project directory
-
Go to pythonanywhere website
-
Click ‘Files’ and upload your zipfile
-
Click Open Bash console
-
Make sure your file is uploaded
-
```zsh upzip [file.zip]
virtualenv –python=python[version] django-envs
cd django-envs
source bin/activate
pip install django==2.2 ```
-
Go to webpage and Click ‘Add a new web app’.
-
Click ‘Manual configuration’
-
Select python version that you chose when you create virtual environment.
-
Modify ‘Source code’ in ‘Code’ section to /home/[your id]/[project]. There is your id below it(Working dirctory: /home/[your id]).
-
Click WSGI configuration file and comment 19th line to 47th line.
-
Uncomment 76th line to 89th line.
-
Modify 81st line to ‘/home/[your id]/[project].
-
Modify 85th line to ‘os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘[project].settings’.
-
Save it and move to ‘web’.
-
Set ‘Virtualenv’ section. Add ‘/home/[your id]/django-envs.
-
Set ‘Static files’ section. URL to ‘/static/ and Directory to ‘/home/[your id]/[project]/static’
-
Go to the top and Click Reload and you will see your website link.