Created
May 13, 2014 14:26
-
-
Save cansadadeserfeliz/2183bf6dab4e90f15ba0 to your computer and use it in GitHub Desktop.
Django: limit choices for model form
This file contains hidden or 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
class ContactForm(forms.ModelForm): | |
def __init__(self, *args, **kwargs): | |
super(ContactForm, self).__init__(*args, **kwargs) | |
self.fields['topic'].queryset = ContactTopic.objects.filter( | |
is_active=True, | |
) | |
class Meta: | |
model = ContactMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment