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)
If you're interested, run the command-line client for your database and type \dt (PostgreSQL), SHOW TABLES; (MariaDB, MySQL), . tables (SQLite), or SELECT TABLE_NAME FROM USER_TABLES; (Oracle) to display the tables Django created.
'django-admin' is not recognized as an internal or external command, operable program or batch file. To fix this, first close the terminal window and relaunch it with administrator privileges. Once you launch the elevated terminal window change directory to where you wish to start your Django project.
Django, by default, uses SQLite3 for development. SQLite3 is a simple relational database engine and your database is automatically created as db. sqlite3 the first time you run python manage.py migrate .
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With