вторник, 15 января 2013 г., 5:56:51 UTC+4 пользователь Amirouche написал:

> Why are you creating two groups of tags ? Why not use a specific widgets 
> like a tree widget ?
>

Great idea! Think, I'll give this a try. 


I think that it would be useful. maybe try widgets 
attrs<https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-types-or-widgets>
>

This:
     class AlbumAdminForm(forms.ModelForm):
       class Meta:
          model = Album
          widgets = {
             'tags_2': FilteredSelectMultiple('tags', False, attrs={'name': 
'tags', 'id':'id_tags'}),
          }
       tags = 
forms.ModelMultipleChoiceField(queryset=Tag.objects.filter(public = True), 
required=False, widget=FilteredSelectMultiple('tags', False ))
       tags_2 = 
forms.ModelMultipleChoiceField(queryset=Tag.objects.filter(public = False), 
required=False, widget=FilteredSelectMultiple('tags', False ))

didn't help at all.

This:
    class AlbumAdminForm(forms.ModelForm):
       class Meta:
          model = Album
       tags = 
forms.ModelMultipleChoiceField(queryset=Tag.objects.filter(public = True), 
required=False, widget=FilteredSelectMultiple('tags', False ))
       tags_2 = 
forms.ModelMultipleChoiceField(queryset=Tag.objects.filter(public = False), 
required=False, widget=FilteredSelectMultiple('tags', False, attrs={'name': 
'tags', 'id':'id_tags'}))
changes the 'id' attribute but not the 'name'.

Are you sure you use the good parameter to pass the queryset to the 
> underlying Field
>

It's just an example with the same queryset for both fields. 

An hack that could probably work is the create a copy the tags field into a 
> tags_2 field in class model definition but it's kind of ugly ;)
>

Indeed, it is. Additionally, I don't know beforehand how many tag groups 
there would be.


Amirouche, thank you for your answer, I really appreciate your help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fGKhtJ_vcNgJ.
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