OK I made some progress on this already.
class MyForm(forms.Form):
def __init__(self, user, data=None):
forms.Form.__init__(self, data)
self.fields['my_options'] =
ModelChoiceField(queryset=SomeModel.objects.get_users_objects(user))
Seems to do what I want.
Is this the most "Django" way of doing things?
On Apr 24, 11:24 am, nickloman <[EMAIL PROTECTED]> wrote:
> Hi there
>
> I want to provide a multi-choice field which filters its results
> according to some external criteria, e.g. the object belongs to a
> user.
>
> I tried something like this:
>
> class MyForm(forms.Form):
> def __init__(self, user):
> self._user = user
> my_options =
> ModelChoiceField(queryset=SomeModel.objects.get_users_objects(self._user))
>
> But of course it doesn't work because the main body of the class can't
> access 'self'.
>
> Any tips?
>
> Nick.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---