I have a Django form in which the current user must select his or her favorite dog, so something like:
class DogForm(forms.Form):
favorite_dog = forms.ChoiceField(label='Select favorite dog.', choices=[])
Unfortunately, the user currently logged in is recorded in the session, which the Django form lacks access to, so I am unable to populate the choices list. The choices should be of the form
[(dog.pk, dog.name) for dog in user.dogs.all()]
Can I somehow feed the choices in through the form constructor? As in, when I construct the form for validation, I tried altering the constructor like
my_form = DogForm(request.POST, user=current_logged_in_user)