django admin中的备用用户选择界面以减少大型站点上的页面大小? [英] Alternate User select interface in django admin to reduce page size on large site?

查看:30
本文介绍了django admin中的备用用户选择界面以减少大型站点上的页面大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于 Django 的站点,其中包含大约 300,000 个用户对象.由于生成的表单大小约为 6MB,因此对于 User 具有 ForeignKey 字段的对象的管理页面需要 非常 很长时间才能加载.当然,生成的下拉菜单也不是特别有用.

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.

推荐答案

ModelAdmin 类提供了一个raw_id_fields 选项,其中显示一个输入字段和一个搜索按钮.它会弹出一个对话框来选择相关的用户对象而不加载所有

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",)

这篇关于django admin中的备用用户选择界面以减少大型站点上的页面大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆