Opened 17 years ago
Closed 17 years ago
#7396 closed (invalid)
django.contrib.admin.site doesn't exist
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | newforms-admin |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When I try to do this proposal convetion at wiki:
A proposal convention: Specifying all admin options in a file called admin.py, and import it in the init.py file of your application module to do the registering during the initialization.
I got this error message: ...
File "/home/projects/django/labs/../labs/research/init.py", line 6, in <module>
admin.site.register(Research, ResearchAdmin)
AttributeError: 'module' object has no attribute 'site'
My project at: /home/projects/django/labs
My research app init.py:
from django.contrib import admin
from labs.research.models import Research
from labs.research.admin import ResearchAdmin
admin.site.register(Research, ResearchAdmin)
If I put the code of research/init.py in research/urls.py it works.
Replying to contato@brunoribeiro.org:
Well I moved the content of research/init.py to my research/admin.py and imported my admin in research/init.py:
import labs.research.admin
And it works.