Opened 7 years ago

Closed 7 years ago

#7396 closed (invalid)

django.contrib.admin.site doesn't exist

Reported by: contato@… 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: UI/UX:

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.

Change History (1)

comment:1 in reply to: ↑ description Changed 7 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Replying to contato@brunoribeiro.org:

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.

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.

Note: See TracTickets for help on using tickets.
Back to Top