By the end of this assignment you will have a fully serviceable CRUD API with user authentication capabilities that will allow School staff to easily manage students and schollastic equipment.
In this assignment we will create a Student Django Model with the following fields
field | required | type | example data |
---|---|---|---|
name | True | string | John W. Watson |
student_email | True | string(email) | [email protected] |
personal_email | False | string(email) | [email protected] |
locker_number | True | int | 137 |
locker_combination | True | string | 37-68-98 |
good_student | True | boolean | True |
Creating and activating VENV
#creating venv
python -m venv <name_of_env>
#activating venv
source <name_of_env>/bin/activate
Installing Django and starting a project with an app
#installing Django
pip install django
#creating project
django-admin startproject school_proj .
#creating student app
python manage.py startapp student_app
Creating Database
createdb school_db
Don't forget to add the app under the INSTALLED_APPS
section in settings.py
and changing from sqlite to postgresql with a database name!
Installing Psycopg3 to speak with PostgreSQL
pip install "psycopg[binary]"
Once the Student Model is completed makemigrations and migrate to the school_db
python manage.py makemigrations
python manage.py migrate
Replace the test.py
file inside your app with the test.py
file already attached to this repository.
Now you can run the test suite by typing the following
python manage.py test
.
means a test passedE
means an unhandled error populated on a testF
means a test completely failed to run