Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternate User select interface in django admin to reduce page size on large site?

I have a Django-based site with roughly 300,000 User objects. Admin pages for objects with a ForeignKey field to User take a very long time to load as the resulting form is about 6MB in size. Of course, the resulting dropdown isn't particularly useful, either.

Are there any off-the-shelf replacements for handling this case? I've been googling for a snippet or a blog entry, but haven't found anything yet. I'd like to have a smaller download size and a more usable interface.

like image 272
David Eyk Avatar asked May 14 '10 19:05

David Eyk


People also ask

How do I restrict access to admin pages in Django?

Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .

Can we customize Django admin panel?

We have a lot of tools in Django to customize it to our own needs and in this article, we'll learn how to customize the admin interface and add multiple features: Let's setup your project, add models into models.py and register your models.

What is admin interface in Django?

One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick, model-centric interface where trusted users can manage content on your site. The admin's recommended use is limited to an organization's internal management tool.


1 Answers

The ModelAdmin class offers an raw_id_fields option, which present a input field and a search button. It presents a popup dialog to select the related user object without loading all

class ArticleAdmin(admin.ModelAdmin):
    raw_id_fields = ("user",)
like image 133
Eric Acevedo Avatar answered Oct 10 '22 22:10

Eric Acevedo