On Thursday, February 24, 2011 05:00:23 am galago wrote:
> I made it that way but i get empty select list
> 
> class ProvinceForm(ModelForm):
>     def __init__(self, *args, **kwargs):
>         super(ProvinceForm, self).__init__(*args, **kwargs)
>         user_provinces =
> UserProvince.objects.select_related().filter(user__exact=self.instance.id).
> values_list('province') self.fields['name'].choices =
> Province.objects.exclude(id__in=user_provinces).values_list('id', 'name')
> 
>     class Meta:
>         model = Province
>         fields = ('name',)
>         widgets = {
>             'name': Select(),
>         }

for self.instance, you'll wnat to do something like this:


self.instance = kwargs.pop('instance')
or add:
def __init__(self, instance, *args, **kwargs):
        self.instance = instance



as for the blank items, verify your query works as expected.  After that I'm 
not sure.

Mike
-- 
If I felt any more SOPHISTICATED I would DIE of EMBARRASSMENT!

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to