Django Admin Site

Our next step is to explore the LocalLibrary administration web site that allows us to create, read, update, and delete data in our database.

https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Admin_site

If you are submitting this assignment to the DJ4E autograder for this assignment, it would be a good idea to check the autograder for specific instructions that the autograder requires for this assignment.

Complete the following sections of the Admin tutorial:

Just as a reminder, when you are running on PythonAnywhere you do not need to do a:

python3 manage.py runserver  # Don't do this on PythonAnywhere

Everytime you make a configuration change. But if you are running on PythonAnywhere and make a configuration change you do need to go into the Web tab and Reload the web server to re-read your updated configuration. There is not harm in reloading your web on PythonAnywhere application too often. So when in doubt, reload :)

Making a Fresh Database

If you want to experiment a bit and you want to wipe out your database and start over, do the following:

cd ~/django_projects/locallibrary
rm db.sqlite3
python3 manage.py migrate

This will wipe out all of your tables and the data in those tables and create fresh and empty tables. Note that this process will also wipe out your superuser accounts and all data you have entered.

The db.sqlite3 file is a normal file - you can back it up and/or copy over it - just make sure to Reload your web application when you change your database.

Some Common Mistakes

Sometimes students set Debug=False in the locallibrary/settings.py file. This should be set to True.

Sometimes when commands like

python3 manage.py migrate

run without error, but the web application will not start on PythonAnywhere, check to make sure your virtual environment is properly set under the Web tab. If you did the installation properly and created a django2 virtual environment, the virtual environment should be set to:

/home/drchuck/.virtualenvs/django2

Replacing "drchuck" with your PythonAnywhere account name.