-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
On 10. 11. 11 8:50, jose osuna perez wrote:
> Sorry xD
> Hi, i wrote the same text in a Spanish blog xD, well I explain my
> problem, I have a table that has the following model:
>
> 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
>
> In my application will logically appears that a project may have
> multiple users that are related to it, the problem is when after a
> call to a function. js, I want to eliminate one of those users.
> For example, "pepe", "pepe1", "pepe2" are users of the project. I
> delete returns "pepe"
> I try in every way like this:
>
> datos=Proyectos.objects.get(id=identificador)
> if request.POST.get('usuarios','')!='':
> datos.usuarios.add(request.POST.get('usuarios'))
> if request.POST.get('usuariosDelete','')!='':
> datos.usuarios=[]
> What this does is to completely eliminate the Projectos, in which the
> user is. Do not know how to remove it from the list of users.
> Thank you very much for the answers. A greeting
>
If I understood correctly, you need to remove a user from a project. You
can do it like this:
 
datos.usarios.remove(User.objects.get(id=user_id))
datos.save()
 
And You can get user_id by sending it in your request.
 
- -- 
end.of.transmission
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iQEcBAEBAgAGBQJOu5chAAoJEAvwFNjlECPx3EkH/0BIdBRq29XGYtNm0F/hVhMi
FU1kI/M+HeN/7Xox9KcK1xCeFVxDUlTcvc2Lbd82nUurSYz/8ZRWBqSdzPmOiqxU
pc86yLzw3WxGsOnR6/MSBkD4SZPw+CF5oBQvaHKLLNwRXHzSCQLoFQqUABsOWFYS
UMtmvHzLn9g1af5L6UxK7VtcBX2jDMyZfsPDFVYIAKxpZuoqYB+ZnKQMnp1i1DSn
AAb6wU99D4sJq5EUvZ//jD+8Ind3DY2pUuf4IL0jX7fsWnQxdZ4ti5C7esbnNsDR
IRp3Q125ja+EDAgAygTYTm1ZJhQPnZH1DZbVoRAnVclSSkVjgQO7DwJruLENWNk=
=JSTx
-----END PGP SIGNATURE-----

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