forked from applegrew/django-select2
-
-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Goal
Don't use a Django Model but a SQL query or dummy data
Problem
No results are shown in template, it's just an empty dropdown menu
Code Snippet
from django import forms
from django_select2 import forms as s2forms
class UserWidget(s2forms.Select2Widget):
def build_attrs(self, *args, **kwargs):
attrs = super().build_attrs(*args, **kwargs)
# some dummy data which will be replaced by an sql query
data = [
{'id': '1', 'text': 'Example1'},
{'id': '2', 'text': 'Example2'},
{'id': '3', 'text': 'Example3'},
{'id': '4', 'text': 'Example4'},
]
attrs['data'] = data
return attrs
class UserForm(forms.Form):
user = forms.ChoiceField(widget=UserWidget)
What am i missing? A ModelSelect2Widget works fine, so the probem should be in my forms.py
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested