Hi all,
I am trying to limit choices on a form generated by
form_for_model. I
created a form class using form_for_instance then inherit
another
class from that and limit the list of choices for a field in
the
__init__(). I feel that I am close but I couldn't manipulate
the
choices.
My classes are as follows:
class AlbumFormForModel(forms.form_for_model(Album)):
pass
class AlbumForm(AlbumFormForModel):
def __init__(self, data = None):
AlbumFormForModel.__init__(self, data)
# do something to manipulate
self.fields['artist'].choices
here
As can be seen from the classes, AlbumForm has a list of
Artists,
which is a query set. But I couldn't manipulate this set and
reassign
it to the choices. I tired things like:
self.fields['artist'].choices.queryset =
self.fields['artist'].choices.queryset.filter(name =
'john')
but this doesn't seem to affect the queryset.
Regards and thanks for any help...
oMat
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|