How to override Django admin's views?

I want to add an upload button to the default Django admin, as shown below:

To do so I overrode the admin/index.html template to add the button, but how can I override the admin view in order to process it?

What I want to achieve is to display a success message, or the error message, once the file is uploaded.


The index view is on the AdminSite instance. To override it, you'll have to create a custom AdminSite subclass (i.e., not using anymore):

from django.contrib.admin import AdminSite
from django.views.decorators.cache import never_cache

class MyAdminSite(AdminSite):
    def index(self, request, extra_context=None):
        # do stuff

You might want to reference the original method at:

Then, you create an instance of this class, and use this instance, rather than to register your models.

admin_site = MyAdminSite()

Then, later:

from somewhere import admin_site

class MyModelAdmin(ModelAdmin):

admin_site.register(MyModel, MyModelAdmin)

You can find more detail and examples at:

Need Your Help

Transformation of files

.net transformation

we have the following problem. We have several sorts of documents (txt, xsl) to transform them into output files (txt) accordingly to some rules. Now it's done by stupid hardcoding but we prefer to...

How do i duplicate a js click counter on my html page

javascript function

I have a javascript click counter on my html page for a my first blog post. Now i want to duplicate the js click counters for all other ten posts on the page, So every blog post has its own indepen...