django-autocomplete-light django 1.8 custom modelform for admin -


i want add autocomplete onetoone field 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 following steps (same list widget 'product' ...):

what have done:

  1. installed :d
  2. added 'autocomplete_light', installed_apps
  3. overrided admin/base_site.html (using custom loader)
  4. url(r'^autocomplete/', include('autocomplete_light.urls')), urlpatterns
  5. autocomplete_light_registry.py model banner , search_fields=['product'],
  6. updated modelform:
class bannerform(autocomplete_light.modelform):     class meta:         model = banner         fields = ['product', 'priority', 'image']         autocomplete_fields = ['product'] 

what i've missed?

following resolved problem:

  1. before admin in installed_apps
  installed_apps = (     'autocomplete_light',     'django.contrib.admin',   ) 
  1. autocomplete_light_registry.py
class bannerautocomplete(autocomplete_light.autocompletemodelbase):     model = banner     search_fields = ('name',)  # banner_obj.product.name     choices = product.objects.all()     limit_choices = 20      autocomplete_light.register(         bannerautocomplete,         attrs={             'placeholder': _(u'имя товара'),             'data-autocomplete-minimum-characters': 1,         },     ) 
  1. manually select autocomplete related field in form:
class bannerform(autocomplete_light.modelform):     class meta:         model = banner         fields = ['product', 'priority', 'image']         autocomplete_names = {'product': 'bannerautocomplete'} 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -