Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since custom admin views are basically just normal views there aren't many specialities. A few things you should consider for a cleaner integration:</p> <ul> <li>Add the url pattern through <a href="https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#adding-views-to-admin-sites" rel="nofollow">get_urls()</a> of the <code>AdminSite</code>.</li> <li>Provide the <code>current_app</code> argument to <code>RequestContext</code> or <code>Context</code> when rendering a template which subclasses admin templates.</li> </ul> <p><strong>EDIT</strong>:</p> <p>Found a an example here: <a href="http://shrenikp.webs.com/apps/blog/show/5211522-add-custom-view-method-for-django-admin-model-" rel="nofollow">http://shrenikp.webs.com/apps/blog/show/5211522-add-custom-view-method-for-django-admin-model-</a></p> <p>Note, that the example doesn't utilize the <code>current_app</code> argument i've mentioned. I suppose your view to generate the PDF just returns a <code>HttpResponse</code> with the appropriate content type rather than rendering a response with a <code>Context</code>, so it's not needed. All in all the <code>current_app</code> only makes sense when you subclass an admin template used by your custom view which actually makes use of <code>current_app</code> somewhere.</p> <p>The example encapsulates the urls and view in a <code>ModelAdmin</code>. It is also possible to do this through a <code>AdminSite</code> subclass, but at least in your use case this is probably overkill.</p> <p>By the way, overriding the <code>change_form.html</code> template for your app to add a button to the standard change view is just fine. There is no special api for this in the admin (unfortunately).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload