I am doing the Activating the Admin Interface
part in djangobook chapter 06. At the end of that part one has to run the development server and go to http://127.0.0.1:8000/admin/
.
However I see this:
Instead of something like this(from the djangobook):
This is strange because I have data stored in a table of my mysql database that is linked to my django project in the settings.py
file.
This is the DATABASES
dictionary in my settings.py
file of my django project:
DATABASES = {
'default': {
'ENGINE': 'mysql',
'NAME': 'mydb',
'USER': 'root',
'PASSWORD': 'mypass',
'HOST': 'localhost',
'PORT': '',
}
}
The mysql prompt shows this:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| mydb |
+--------------------+
3 rows in set (0.00 sec)
mysql> use mydb;
mysql> show tables;
+----------------------------+
| Tables_in_mydb |
+----------------------------+
| auth_group |
| auth_group_permissions |
| auth_message |
| auth_permission |
| auth_user |
| auth_user_groups |
| auth_user_user_permissions |
| books_author |
| books_book |
| books_book_authors |
| books_publisher |
| django_admin_log |
| django_content_type |
| django_session |
+----------------------------+
14 rows in set (0.00 sec)
Why am I not seeing the contents of mydb
in my admin page?
Might be relevant:
mysql> select User from mysql.user;
+------------------+
| User |
+------------------+
| root |
| debian-sys-maint |
| root |
| root |
+------------------+
4 rows in set (0.00 sec)
You need to keep reading http://django-book.readthedocs.org/en/latest/chapter06.html#adding-your-models-to-the-admin-site
There’s one crucial part we haven’t done yet...
Within the books directory (mysite/books), create a file called admin.py, and type in the following lines of code:
from django.contrib import admin
from mysite.books.models import Publisher, Author, Book
admin.site.register(Publisher)
admin.site.register(Author)
admin.site.register(Book)