Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10292 closed (invalid)

AdminSite docs are incorrect

Reported by: bugmenot Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords: AdminSite
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adminsite-objects

could use some work. The second paragraph, on subclassing AdminSite, should have a code example, since it is not the same as using the builtin admin.site. You need to register with myadmin.register() instead of admin.site.register(); this is not obvious. A short code snippet would make it obvious.

The first code example, registering the default admin site in the usual way, is next to useless in a section about how to do things outside of the usual way. The second code example is just incorrect:

# urls.py
from django.conf.urls.defaults import *
from myproject.admin import admin_site

urlpatterns = patterns('',
    ('^myadmin/', include(admin_site.urls)),
)

should be:

# urls.py
from django.conf.urls.defaults import *
from myapp.admin import myadmin

urlpatterns = patterns('',
    ('^myadmin/',    include(myadmin.root)),
)

since the project itself doesn't have an admin.py, and presumably you're not making a whole new app just to administer itself. AdminSite objects have no "urls" attribute, you want to register the "root" attribute. And it would be much clearer if, as mentioned, you included a code snippet before that shows how to subclass AdminSite and register your objects with it.

The last code snippet on the page is also incorrect; "urls" should be "root."

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by Alex

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

These code examples are completely correct for Django's latest trunk, which is what the online docs are for.

comment:2 Changed 5 years ago by bugmenot

Then they should be marked "Changed in development version." I'm pretty sure what's on the web is labeled 1.0 docs.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.