Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Enhancement for custom columns in django admin list screens

Project description

Django’s automatic admin list screens are awesome! But sometimes you need custom columns to display information that requires some big queries or perhaps some heavy computation. This can slow down displaying the entire list screen. This app is meant to address that need by converting a custom column in to one that can be dynamically loaded over AJAX on user action.

Regular custom column

Django allows you to use admin methods to render a column on the change list screen. For example:

class MyAdmin(admin.ModelAdmin):
    list_display = ('name', 'age', 'custom_column')

    def custom_column(self, obj):
        return foo_takes_time(obj)

    custom_column.short_description = 'Custom Title'

Lazy custom column

Lazy custom columns are loaded over AJAX by user action. This is achieved by adding a decorator over any custom list column function you’ve added in your ModelAdmin class.

from lazy_admin import lazy_admin_column

class MyAdmin(admin.ModelAdmin):
    change_list_template = 'lazy_admin/change_list.html'

    list_display = ('name', 'age', 'custom_column')

    def custom_column(self, obj):
        return foo_takes_time(obj)

    custom_column.short_description = 'Custom Title'

Note the change_list_template of the MyAdmin class. This template loads the javascript necessary to handle the AJAX interaction.


Ideally, install the package in your virtual environment.

pip install django_lazy_admin

Now, add the app to your django setting INSTALLED_APPS.


And, install the URL handler in your root url conf or in some other url configuration file.

urlpatterns = patterns('',
    url(r'^admin/lazy/', include('lazy_admin.urls')),

And, you’re done!


You can turn off all lazy columns by the following in your main django file.


The column content is rendered using the lazy_admin/lazy_column.html template. You can over-ride this in your own app. Or you can use a parameter to the decorator.



  • Support Model class methods used as custom columns as well with the same decorator.


The primary author of this package is Gautam Kachru


BSD 3-clause. See LICENSE file.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django_lazy_admin, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_lazy_admin-1.0.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page