Getting
Started with Django
389
This code first imports the model we want to register,
Topic
u. The dot
in front of
models
tells
Django to look for models.py in the same directory as
admin.py. The code
admin.site.register()
tells Django to manage our model
through the admin site v.
Now use the superuser account to access the admin site. Go to
http://
localhost:8000/admin/, and enter the username
and password for the super-
user you just created. You should see a screen like the one in Figure 18-2.
This page allows you to add new users and groups, and change existing
ones. You can also work with data related to the
Topic
model that we just
defined.
Figure 18-2: The admin site with Topic included
n o t e
If you see a message in your browser that the web page is not available, make sure you
still have the Django server running in a terminal window. If you don’t, activate a
virtual environment and reissue the command
python manage.py runserver
. If you’re
having trouble viewing your project at any point in the development process, closing
any open terminals and reissuing the
runserver
command is a good first troubleshoot-
ing step.
Do'stlaringiz bilan baham: