Is there a more efficient, or cleaner way to do the following?
class SpamForm(ModelForm):
some_choices = fields.MultipleChoiceField()
def __init__(self, *args, **kwargs):
super(SpamForm, self).__init__(*args, **kwargs)
self.fields['some_choices'].choices = [[choice.pk, choice.description] for choice in self.instance.user.somechoice_set.all()]
class Meta:
model = Spam
This is to populate the new form with choices that pertain to the current request.user
(which is set on the instance that's passed into the form). Is there a better way?