1 2 3 4 5 6 | class EventForm(forms.Form):
events = forms.ModelChoiceField(queryset=Contest.objects.none(), required=True)
def __init__(self, eventUser, *args, **kwargs):
super(EventForm, self).__init__(*args, **kwargs)
self.fields['events'].queryset = Event.objects.filter(user__exact = eventUser.id)
|
More like this
- ModelChoiceField with option groups by anentropic 1 year, 5 months ago
- CustomChoiceField, Selectable label field version of ModelChoiceField by mauro 5 years, 2 months ago
- filtered ModelChoiceField queries by robharvey 5 years, 2 months ago
- ModelChoiceField with optiongroups by anentropic 3 years, 2 months ago
- Adding buttons to submit line in a Admin page by marinho 5 years ago
Comments