Which one error ?

Many thanks,

Serge


+380 636150445
skype: skhohlov


On Tue, Jun 18, 2013 at 1:56 PM, Lucas Lins <[email protected]> wrote:

> Hi.
> I ran into a problem and have searched the group, in the official django
> and the internet and could not solve the problem.
> I created a form that lists all the groups created and all user
> created and this adds form users within groups.
> Already tried two ways and both give error
>
>
> form.py
>
> class alterar_usuario(forms.Form):
>  Usuario = forms.**ModelMultipleChoiceField(**queryset=
> User.objects.all() )
> Grupo = forms.**ModelMultipleChoiceField(**queryset = Group.objects.all())
>
>
> (way 1)
> view.py
>
> def cadastrarUsuarioGrupo(request):
>
>     if request.method == "POST":
>         form = alterar_usuario(request.POST)
>
>         if form.is_valid():
>             Usuario = form.cleaned_data['Usuario']
>             Grupo = form.cleaned_data['Grupo']
>
>             usuarioOb = User.objects.get(id = Usuario)
>             groupOb = Group.objects.get(id = Grupo)
>
>             usuarioOb.groups.add(groupOb)
>
> (way 2)
> view.py
>
> def cadastrarUsuarioGrupo(request):
>
>     if request.method == "POST":
>         form = alterar_usuario(request.POST)
>
>         if form.is_valid():
>             Usuario = form.cleaned_data['Usuario']
>             Grupo = form.cleaned_data['Grupo']
>             usuarioOb = User.objects.filter(id = Usuario)
>             groupOb = Group.objects.filter(id = Grupo)
>             for user, group in usuarioOb, groupOb:
>               user = usuarioOb.user
>               group = grupoOb.groups
>               usuer.groups.add(group)
>
> Grateful.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to