Admin
The admin panel is a user interface for managing the application, accessible through the browser. In the admin.py
file, we can add the model just created with the following command:
from models import Person admin.site.register(Person)
All the models can be accessed by a user interface at:
http://127.0.0.1:8000/admin/
At this link, the user name and password are required. We create that with the following command:
python manage.py createsuperuser
Then we type a username and password (in my case, andrea/a
).
Now, we can explore the panel that follows:
Clicking on Persons, we will see all Person
objects shown by name (because the__unicode__
function in the model refers to the name field):
Shell interface
The Django framework also provides a shell to explore the created models and test them. To start it, we type the following in the terminal:
python manage.py shell
Now we can import the Person
model and play with it:
In [1]: from addressesapp.models import Person In [2]: newcontact = Person...