Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queryset from choices #509

Merged
merged 5 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions django_select2/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ def get_queryset(self):
"""
if self.queryset is not None:
queryset = self.queryset
elif hasattr(self.choices, 'queryset'):
queryset = self.choices.queryset
elif self.model is not None:
queryset = self.model._default_manager.all()
else:
Expand Down
2 changes: 0 additions & 2 deletions tests/testapp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class AddressChainedSelect2WidgetForm(forms.Form):
queryset=Country.objects.all(),
label='Country',
widget=ModelSelect2Widget(
model=Country,
search_fields=['name__icontains'],
max_results=500,
dependent_fields={'city': 'cities'},
Expand All @@ -198,7 +197,6 @@ class AddressChainedSelect2WidgetForm(forms.Form):
queryset=City.objects.all(),
label='City',
widget=ModelSelect2Widget(
model=City,
search_fields=['name__icontains'],
dependent_fields={'country': 'country'},
max_results=500,
Expand Down