Django admin, override dropdown with selection from popup window

自作多情 提交于 2020-01-15 11:07:40

问题


In a one-to-many relationship, how can I override the drop-down menu in the change-form to be able to select value from popup window, specially when dropdown could hold a pretty long list which may slowdown the page load.


回答1:


Just found the answer:

raw_id_fields is a list of fields you would like to change into an Input widget for either a ForeignKey or ManyToManyField:

class ArticleAdmin(admin.ModelAdmin): raw_id_fields = ("newspaper",)

https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

The question now is how can I display a user friendly value instead of the Id returned from the popup.



来源:https://stackoverflow.com/questions/24400564/django-admin-override-dropdown-with-selection-from-popup-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!