I want add autocomplete for OneToOne field to django-admin
class Banner(models.Model):
product = models.OneToOneField(Product, null=True)
class BannerAdmin(admin.ModelAdmin):
form = BannerForm
stucked on https://django-autocomplete-light.readthedocs.org/en/stable-2.x.x/tutorial.html?highlight=tutorial#tutorial - anything changed after all following steps (same list widget for 'product' ...):
What I have done:
- installed :D
- added 'autocomplete_light', to INSTALLED_APPS
- overrided admin/base_site.html (using custom loader)
- url(r'^autocomplete/', include('autocomplete_light.urls')), to urlpatterns
- autocomplete_light_registry.py with model Banner and search_fields=['product'],
- updated modelform:
class BannerForm(autocomplete_light.ModelForm): class Meta: model = Banner fields = ['product', 'priority', 'image'] autocomplete_fields = ['product']
What I've missed?
Following resolved my problem: