Phishion
V2EX  ›  Django

Django 后台外键数据过多,进入页面卡死

  •  
  •   Phishion · Jul 22, 2018 · 3830 views
    This topic created in 3047 days ago, the information mentioned may be changed or developed.

    我有一个表设置了外键,外键大概有上千条内容吧,这个外键在 Django admin 后台以 select 标签显示出来,结果因为外键条目过多,每次 admin 后台进入这张表的时候,都会卡很久才能进去。

    网上没找到解决方法,向大佬求助一个解决方案。

    wplct
    wplct
    Jul 22, 2018❤️1
    1
    raw_id_fields 了解一下
    zhchyu999
    zhchyu999
    Jul 22, 2018 via Android
    2
    那是你 SQL 语句的问题,跟 Django 有什么关系
    tinypig
    tinypig
    Jul 22, 2018
    3
    可以改造一下这个控件,改成 ajax 查询的,或者把这个字段设置成 readonly
    Phishion
    Phishion
    OP
    Jul 22, 2018
    4
    @wplct 这个比较方便,感谢大佬们提供帮助
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1243 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 17:29 · PVG 01:29 · LAX 09:29 · JFK 12:29
    ♥ Do have faith in what you're doing.