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.

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 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 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/ file. This should be set to True.

Sometimes when commands like

python3 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:


Replacing "drchuck" with your PythonAnywhere account name.