Hello, I have a question that I have not been resolved, well three,
took
and a few days researching the subject,
but this being impossible I would appreciate your help, as they are
the last 3 points I have left to complete a project:

I have the class:

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 appear 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: "foo", "pepe1", "pepe2" are users of the project. I
delete returns "foo"
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 Project, in which the
user is.

Or there is the following;
if request.POST.get('usuariosDelete','')!='':
        for i in request.POST.getlist('usuarios'):
               usuario=User.objects.get(id=i)
               datos.usuarios.remove(usuario)
This second form can not get any results .......

And I can not create stories or intermediate classes, because the
model
is already defined.
Thank you very much beforehand, really it's something I need,
Thank 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.

Reply via email to