- Install
dockeranddocker-compose. - run
make build && make runin the root directory (this one)
Simplified tree diagram
. # Contains docker setup and Makefile
├── docker-compose.yml # defines setup of PostgreSQL and Django
├── Dockerfile # defines pickmybruin/backend Docker image
├── initialize.sh # sets up Django container (runs migrations and then boots server)
├── Makefile # contains very useful helper commands
└── src # Contains all Django code
├── pickmybruin # Contains code relating to the entire website
│ ├── keys.py # put confidential info in here
│ ├── settings.py # global settings (please keep confidential info out of here)
│ ├── urls.py # global URLs (usually imports app URLs too)
└── users # One app for just users
├── admin.py # sets up /admin pages
├── models.py # contains class declarations and methods
├── serializers.py # contains serializers for classes
├── tests.py # necessary (pls)
├── urls.py # sets up app specific URLs
└── views.py # sets up responses to URLs
make buildcreates thepickmybruin/backendimagemake runstarts up the PostgreSQL and Django containersmake restartrestarts the Django container (useful when you edit code)make sshstarts a bash session in the latest Django containermake run_commandruns a command inside the latest Django containermake run_command cmd="echo hi"will runecho hiinside the latest Django container
make shellstarts amanage.py shell_plusinside the latest Django container- If you don't know what this means, that's fine
- Run
make run_command cmd="src/manage.py startapp $APPNAME- This creates a new skeleton folder for your new app
- YOU MUST ADD THIS APP TO
src/pickmybruin/settings.pyINSTALLED_APPSFOR THE APP TO BE DISCOVEREDR'users',adds theusersapp to the Django project. Big surprise.
- Add your code
- Add tests to
tests.py - Add your models to
admin.py - Import your urls.py in
src/pickmybruin/urls.py - Run the tests
- Submit a PR
NOTE: you don't really need to understand this, but this is how Django will create tables for the models
| id | first_name | last_name | (salted and hashed) password | |
|---|---|---|---|---|
| 1 | [email protected] | Mark | Tai | verysecurepassword |
| 2 | [email protected] | John | Doe | corgisarecute |
| id | user_id | bio |
|---|---|---|
| 1 | 1 | Let me know if these examples suck |
| 2 | 2 | marktai.com/#corgis for all your corgi needs |
| id | name |
|---|---|
| 1 | CS |
| id | profile_id | major_id | bio |
|---|---|---|---|
| 1 | 2 | 1 | I will teach you the ways of corgis |