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) | johnnyBoy@school.com |
| personal_email | False | string(email) | johnnyBoy@gmail.com |
| 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/activateInstalling 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_appCreating Database
createdb school_dbDon'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 migrateReplace 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 passedEmeans an unhandled error populated on a testFmeans a test completely failed to run