##Django kick start- file structions forms check for user input, urls routes the user input (i.e. request) and send it to the right destination (i.e. url destination), views defines the http interaction between user
Pip requirement packages:
Django
django-debug-toolbar
django-rest-framework
firebase_admin
fcm-django
djangorestframework-jwt
django-extensions
django-simple-history
eva's requiremnt.txt pip install --no-deps -r requirements.txt
mkdir env mkdir env/bin
source env/bin/activate # start virtual space deactivate # turn off
3. to avoid python selecting higher but not eligible versions for build that lead to build fail, try starting with an empty virtual environment
DJANGO_SETTINGS_MODULE=campusalert.settings python manage.py runserver
NOTE: there is a risk that installing firebase_admin can cause damage to the OpenSSL package in Python distro. See here on how to fix it: https://stackoverflow.com/questions/73830524/attributeerror-module-lib-has-no-attribute-x509-v-flag-cb-issuer-check
After that, you need to get the Firebase secret JSON file from the Discord server and put that somewhere on your computer. Then have your environment variable GOOGLE_APPLICATION_CREDENTIALS
point to it.
If you have Linux, Linux subsystem for Windows, or MacOS, you can do the following to add it to Bash:
sudo nano ~/.bashrc
Then add this line
export GOOGLE_APPLICATION_CREDENTIAL=<path to the JSON file>
Make sure to restart your terminal and you are in Bash and not zsh. zsh requires similar steps.
To start the program, run
python3 manage.py runserver 8080
Every time you update the field name or add new fields to a model, you MUST run this before committing!
python3 manage.py makemigrations
python3 manage.py migrate
- and accept each rename correctly in the terminal prompts
Finally, go into admin.py
and write
admin.site.register(NameOfYourModel)
You might have to do this occassionally when Django is being super stubborn and refuse to migrate due to the data in your tables.
python manage.py reset_db
After that, delete every Python file in migrations
as well. Then follow the step above to makemigration and migrate.
python manage.py createsuperuser
You can ignore the warning about short password in development environment.
Kevin's admin account:
- username: thundertonic
- password: 123
/auth/whoami
- returns the user info
- API is auto generated by Django
- reserved for debugging purposes, auto generated by Django
- Use todo tree vscode plugin to see what work still needs to be done. This plugin detects all of the TODOs and summarize it in one tab.
Building layout images: