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
class Experimentos(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()
proyecto=models.ForeignKey(Proyectos)
usuarios=models.ManyToManyField(User)
experimentos=models.ManyToManyField("self")
documentos=models.ManyToManyField(Documentos)
class Meta:
db_table='Experimentos'
.
I want to eliminate only one of the experiments which may contain a
Project
I try like this:
if request.POST.get('experimentosDelete','')!='':
for i in request.POST.getlist('experimentosDelete'):
exp=Experimentos.objects.get(proyecto=datos,id=i)
exp.experimentos.remove(request.POST.get('experimentosDelete'))
The result is that it does nothing ....... and otherwise remove whole
objects, not the relationship.I don't know .
I greatly appreciate your help in all questions.
The remove() method takes objects, not ids.
Cheers
Tom
.......
I don't know how to make this......
Anyone who say me ??? Thanks a lot