Created
February 25, 2017 12:55
-
-
Save hseritt/2dec6052f3da07198dcdcfc2f081ae99 to your computer and use it in GitHub Desktop.
Django form field: somewhat complex queryset filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.fields['watchers'] = forms.ModelMultipleChoiceField( | |
queryset=User.objects.filter( | |
Q(contact__organization=self.request.user.contact.organization)| | |
Q(contact__organization__org_type__in=['Owner',])| | |
Q(groups__name__in=['issues_admin', 'cases_admin']) | |
).distinct().order_by('username') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment