Code

Opened 4 years ago

Closed 3 years ago

#12469 closed (fixed)

get_urls docs in ModelAdmin can be extended

Reported by: benc Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords: get_urls ModelAdmin
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by russellm)

It might help to explain three things regarding custom views in ModelAdmin
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_urls

  1. The path in the example r'^my_view/$' will be accessed at /admin/myapp/mymodel/my_view/
  1. self.my_view in the example means that you probably want to define the view inside the MyModelAdmin Class so it has access to the ModelAdmin.
  1. my_view will be called with the request and the ModelAdmin instance as arguments:

def my_view(request, model_admin):

A simple class with get_urls and a view will be best.
Thanks

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by russellm

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by timo

  • Resolution set to fixed
  • Status changed from new to closed

(In [15113]) Fixed #12469 - Add a few clarifications to the ModelAdmin.get_urls() docs. Thanks benc for the suggestions.

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.