django-autocomplete-light

Problem when creating a form with both django-autocomplet-light and and bootstrap-datepicker-plus widgets

隐身守侯 提交于 2021-02-08 08:53:16
问题 I am trying to create a form which uses two different widgets: - some fields are using django-automplete-light ModelSelect2 widget - another field is using bootstrap_datepicker_plus DatePickerInput widget However, I can't manage to make them both work: when I create a form with DatePickerInput only, the calendar shows correctly, but when I add fields using ModelSelect2, the calendar doesn't popup anymore. Does anybody know what could cause this problem and how to solve it? In settings.py I

Django-autocomplete-light: allow free text

雨燕双飞 提交于 2021-02-07 09:27:24
问题 I am using autocomplete_light.MultipleChoiceWidget from django-autocomplete-light==1.4.13 to fill in a ManyToManyField. It only allows selecting items from existing choices. Is there a way to allow users to create new items on the fly with django-autocomplete-light? If not, is there any solid alternative to it with good Django integration, which supports this feature? 回答1: There is an issue on GitHub by @blueyed. Here is an answer from the author: Here's an example for v2 https://github.com

django-autocomplete-light add parameter to query url

一曲冷凌霜 提交于 2021-01-27 06:37:45
问题 I'm trying to pass some data along to the autocomplete_light.AutocompleteModelBase so I can exclude some models from the search. I'm trying to use the Dependencies info in the docs here but I can seem to get it. The id of the input is id_alternate_version-autocomplete , so I'm trying: $("#id_alternate_version-autocomplete").yourlabsWidget().autocomplete.data = {'id': 'foo'}; But the url called looks like http://127.0.0.1:8000/autocomplete/FooAutocomplete/?q=bar I want: http://127.0.0.1:8000

Django Autocomplete Light - “The results could not be loaded”

喜夏-厌秋 提交于 2020-07-09 14:01:04
问题 I'm using Django-autocomplete-light on a small application. The UI seems to work, and I can select from some visible values. The problem arises when I type one or more letters into the box. Normally it should filter/select the results, instead, I get the error "The results could not be loaded" (see picture). Seems like the jquery is working fine, except for not filtering when I type in the box. Happy to add more code, just not sure what I need to add yet. models.py class Encounter(models

How to show related object popup when the user clicks on selected autocomplete field options in Django admin?

青春壹個敷衍的年華 提交于 2020-06-17 09:43:26
问题 I want to show the standard related object popup when the user clicks on a selected option in a Django admin autocomplete multi-select field, like it works when clicking the ForeignKey field pencil icon 🖉. The models are as follows: class Author(models.Model): name = models.CharField(_('name'), max_length=160) class Book(models.Model): authors = models.ManyToManyField(Author, verbose_name=_('authors'), blank=True) ... Is it possible to do this by extending Django admin? 回答1: I found that

Django Autocomplete Light … PK vs display field

亡梦爱人 提交于 2020-05-14 09:03:09
问题 I am using DAL to provide a selectable dropdown list like this: class OccupationsModel(models.Model): Occupation_Code = models.CharField(max_length = 20, primary_key=True) Occupation_Title = models.CharField(max_length = 150, unique=True) Occupation_Desc = models.CharField(max_length = 1000) class Meta: db_table = 'Occupation_Info' def __str__(self): return self.Occupation_Title Note here that occupation_code is my PK while I am using str to show occupation_title as my display. Mostly

Different implementations for Autocomplete-light

*爱你&永不变心* 提交于 2020-01-06 20:19:28
问题 I was able to implement the autocomplete-light function using a class based view format: class UserAccountsUpdate(UpdateView): context_object_name = 'variable_used_in `add_user_accounts.html`' form_class = AddUserAccountsForm template_name = 'add_user_accounts.html' def add_user_institution_details(request): ###code### With this form: class AddUserAccountsForm(autocomplete_light.ModelForm): required_css_class = 'required' name = forms.CharField( required=True, widget=autocomplete_light

Different implementations for Autocomplete-light

只谈情不闲聊 提交于 2020-01-06 20:16:36
问题 I was able to implement the autocomplete-light function using a class based view format: class UserAccountsUpdate(UpdateView): context_object_name = 'variable_used_in `add_user_accounts.html`' form_class = AddUserAccountsForm template_name = 'add_user_accounts.html' def add_user_institution_details(request): ###code### With this form: class AddUserAccountsForm(autocomplete_light.ModelForm): required_css_class = 'required' name = forms.CharField( required=True, widget=autocomplete_light

can't make autocomplete_light filter taggit tags based on request user

对着背影说爱祢 提交于 2020-01-04 08:02:28
问题 I apologize if this has nothing to do with both apps. The following snippet will throw me a "cannot filter a query once a slice has been taken": models.py class Cartao(models.Model): ... user = models.ForeignKey(settings.AUTH_USER_MODEL) tags = TaggableManager() autocomplete_light_registry.py import autocomplete_light from taggit.models import Tag class TagAutocomplete(autocomplete_light.AutocompleteModelBase): autocomplete_js_attributes={'placeholder': 'Ex: pessoal, serviços',} def choices

can't make autocomplete_light filter taggit tags based on request user

好久不见. 提交于 2020-01-04 08:02:07
问题 I apologize if this has nothing to do with both apps. The following snippet will throw me a "cannot filter a query once a slice has been taken": models.py class Cartao(models.Model): ... user = models.ForeignKey(settings.AUTH_USER_MODEL) tags = TaggableManager() autocomplete_light_registry.py import autocomplete_light from taggit.models import Tag class TagAutocomplete(autocomplete_light.AutocompleteModelBase): autocomplete_js_attributes={'placeholder': 'Ex: pessoal, serviços',} def choices