I think you need to look up a specific Proyecto object before trying to
add users to it. So:

proyecto = Proyecto.objects.get(...)
for i in request.POST.getlist('usuarios'):
    usuario = User.objects.get(id=i)
    proyecto.usuarios.add(usuario)

Hope that helps,

Brett


On 10/11/11 4:15 AM, "jose osuna perez" <osunaperezj...@gmail.com> wrote:

> I have reviewed the document
>https://docs.djangoproject.com/en/dev/topics/db/queries/
>but I can not insert the field users, the models.py table, I try as
>follows, is this what was spinning in the other issue, not the
>complete code, thanks:
>
>for i in request.POST.getlist('usuarios'):
>  usuario=User.objects.get(id=i)
> Proyectos.usuarios.add(usuario)
>
>And my models.py file it's the next:
>
>class Proyectos(models.Model):
>    titulo=models.CharField(max_length=100)
>    creacion=models.DateField(default=datetime.datetime.now)
>    estado=models.CharField(max_length=30)
>    objetivo=models.TextField(null=True)
>    conclusion=models.TextField(null=True)
>    porcentaje=models.IntegerField()
>    modificado=models.DateTimeField(default=datetime.datetime.now)
>    autor=models.IntegerField()
>    usuarios=models.ManyToManyField(User)
>    proyectos_rel=models.ManyToManyField("self")
>    documentos=models.ManyToManyField(Documentos)
>    class Meta:
>        db_table='Proyectos'
>    def __unicode__(self):
>        return self.titulo
>
>Thanks you
>
>-- 
>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.
>

-- 
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