Overriding Built-in Views

At times the default admin views just don’t cut it. You can easily swap in your own custom view for any stage of the admin interface; just let your URL “shadow” the built-in admin one. That is, if your view comes before the default admin view in the URLconf, your view will be called instead of the default one.

For example, we could replace the built-in “create” view for a book with a form that lets the user simply enter an ISBN. We could then look up the book’s information from http://isbn.nu/ and create the object automatically. The code for such a view is left as an exercise for the reader, but the important part is this URLconf snippet:

(r’^admin/bookstore/book/add/$’, ‘mysite.books.admin_views.add_by_isbn’),

If this bit comes before the admin URLs in your URLconf, the add_by_isbn view will completely replace the standard admin view.

We could follow a similar tack to replace a delete confirmation page, the edit page, or any other part of the admin interface.

Back to Tutorial

Creating Custom Admin Views
Webapps Directory

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?