I have been given a small legacy db (mysql) to work with, and therefore, I have tried to use the inspectdb command in django.
So, I use something like:
python manage.py inspectdb > models.py
It works fine, and I take the models.py and copy the class it created into my app (searchapp) as a models.py file.
I have done a syncdb, and everything went fine. Results are as expected.
Now, I have tried to add this model into my admin site, using:
from searchapp.models import Abaqus
from django.contrib import admin
admin.site.register(Abaqus)
stored in a file called admin.py (Abaqus is the name of the class generated by inspectdb and searchapp is the app name). However, I am not able to see the app on the admin site. I have checked my settings.py and it includes the ‘searchapp’.
I was wondering if someone could point me in the right direction..
I suspect admin.py is not loaded. You could check this by putting a debug statement just above the
registercall:If this is in fact the case, the correct way to ensure
admin.pyis loaded is to calldjango.contrib.admin.autodiscover()at the beginning of your main url conf.If you’ve written no admin classes and don’t want an
admin.py, you can calladmin.site.register(Abaqus)right below where the model is defined, inside models.py.If you have an admin module structured like the following,
import adminwithin models.py to ensure the code is run:Another possible cause would be that you are missing the permissions to edit the model. Double check that you are logged in as a superuser.