问题
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