So, let's say, at the last minute (in the view), I decided that I want to specify the default value for the field and make it hidden, for example:
form.fields['coconut'] = forms.ModelChoiceField(label="", widget=forms.HiddenInput(), queryset=swallow.coconuts.all(), initial=some_particular_coconut)
My question is this: do I really need to specify the request here? I mean, I already know, from the initial, it’s the coconut that I’m talking about. Why do I also need to point out that the universe of affordable coconuts is the set of coconuts that this particular swallow wears (huskily)?
Is there a way that I can refrain from specifying a set of queries? A simple drop causes django to raise a TypeError.
If it's really needed, isn't it a little wet?
source
share