22👍
Since Django 2.0, you can use autocomplete_fields
to generate autocomplete fields for foreign keys.
class UserAdmin(admin.ModelAdmin):
search_fields = ['username', 'email']
class RedAdmin(admin.ModelAdmin):
autocomplete_fields = ['customer']
10👍
Django has no built-in autocomplete functionality for foreign keys on admin but the raw_id_fields
option may help:
class RedAdmin(admin.ModelAdmin):
raw_id_fields = ("customer", )
If you want real autocomplete then you have to use 3rd-party app like django-autocomplete-light
or some of the other solutions.
- Django Enter a valid date. validation error
- Issues with queryset and slicing
- How to test coverage properly with Django + Nose
- In Django ORM, "values" and "annotate" are not working to group by
- Celery: auto discovery does not find tasks module in app
Source:stackexchange.com