- Install
docker
anddocker-compose
. - run
make build && make run
in 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 build
creates thepickmybruin/backend
imagemake run
starts up the PostgreSQL and Django containersmake restart
restarts the Django container (useful when you edit code)make ssh
starts a bash session in the latest Django containermake run_command
runs a command inside the latest Django containermake run_command cmd="echo hi"
will runecho hi
inside the latest Django container
make shell
starts amanage.py shell_plus
inside 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.py
INSTALLED_APPS
FOR THE APP TO BE DISCOVEREDR'users',
adds theusers
app 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 | me@marktai.com | Mark | Tai | verysecurepassword |
2 | you@marktai.com | 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 |