Join Caleb Smith for an in-depth discussion in this video Examining the Django admin, part of Learning Python and Django (2015).
- Let's register our item model with Django's built-in admin…so that we can log in as a site administrator…to create, edit, delete,…and view the inventory items in the database.…First, we'll open up the admin.py file…in the inventory folder of the project…in a text editor.…This file has an import at the top…as a place holder to help us get started.…Now, we'll remove the comment and add some code.…First, we need to import our item model…from our models module in the inventory app.…
Now that we have the item model…we can register it with the admin…using admin.site.register…and pass it the argument Item.…This is enough to register our model with the admin.…Now, we need to have a superuser so that we can log in…in the admin web interface.…For this purpose, there is a manage.py subcommand…called create superuser.…In the terminal, I'll change the directory…into Exercise Files where the manage.py file is.…For you, this is wherever you're running the project.…
Now that I'm in the folder where manage.py is…I'll type "python manage.py"…
- Creating a new Django project
- Defining Django models and fields
- Querying data with the Django ORM
- Building views and templates
Skill Level Intermediate
Q: pip says it was installed correctly, and I've updated the PATH variable as shown, but the pip --version command isn't working. Why?
A: Depending on your computer's setup, you'll need to restart your terminal/command prompt before the additions you've made to the PATH variable are respected. With some setups, even that won't be enough, and you may need to restart the entire machine before you are able to use the pip command directly.