- Ensure asdf is installed
- Ensure a recent version of Python (either 3.9 or 3.10) is installed in asdf
- From the command line in the /api folder, run
pip3 install -r requirements.txt - Confirm libraries have been installed correctly - e.g.,
python3 -m django --versionshould output the version number of Django as specified in requirements.txt - To run the webserver locally, cd in /api/registration, then run
python3 manage.py runserver- if it's running correctly, the terminal output will say that the development server is running on your local host on a port (default :8000).- the first time you run this, you'll get warning messages saying that you have unapplied migrations.
- To run the database migration locally, execute
python3 manage.py migrate- the first time you run this, you'll get warning messages saying that you have unapplied migrations.
- To run the database migration locally, execute
python3 manage.py migrate - To access the Django admin panel locally, execute
python3 manage.py createsuperuserto create a superuser in your local database. You'll need to remember the credentials you create in order to access the admin panel when running the Django server locally. - Log in to the admin panel by navigating to the '/s/administration/raw' endpoint (at the address your server is running on)
- Ensure your Postgres server is running locally
- Create a new database
- Make a copy of the api/registration/registration/settings.py file and name it local_settings.py. Update the values in
DATABASES {}with the values specific to your local database.
-
In
/cas-hackathon-reg/api/registration:- run
make migrateif there are new migrations - run
make loadfixturesif there are new fixtures - update
local_settingswith any new changes from the mainsettingsfolder
- run
-
If you hit a migration conflict: (TBC, but for now)
- Delete the newly pulled migrations
- Run
make makemigrationsto recreate them relative to your existing migrations (mainly to update dependencies, I think?)
- For initial setup, I ran
django-admin startproject registrationfrom within the /api directory. This auto-generated a subfolder called /registration (and a subfolder by the same name), and a default manage.py file. Note that here,registrationis the name of the project, not the name of the app. In hindsight, something likeobpswould have been a better project name thanregistration... - From within the /api/registration folder, I ran
python3 manage.py startapp regto create a new app calledregwithin theregistrationproject. This command auto-generated a subdirectory calledregand inserted some default files and amigrationssubfolder. - After defining the classes in reg/models.py, I ran
python3 manage.py makemigrations reg, which auto-generated a new file called 0001_initial.py in the /migrations subfolder. Then I ranpython3 manage.py sqlmigrate reg 0001, which outputs to the terminal the SQL commands that will be executed (outgenerated by Django) when the migration is performed.