Add to database
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.
Re: Add to database
Thanks you¡¡¡ I'll try to see if it works -- 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.
delete a field( many to many)
Hola, bueno les explico mi problema, tengo 1 tabla que tiene el siguiente modelo: 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 En mi aplicación te aparece que logicamente, un Proyecto, puede tener varios usuarios que esten relacionados al mismo, el problema viene cuando tras una llamada a una funcion .js, quiero eliminar uno de esos usuarios. Por ejemplo, "pepe","pepe1","pepe2" son usuarios del proyecto. Quiero borrar el que devuelve "pepe" Lo intento de mil maneras como esta: 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=[] Esto lo que hace es eliminarme completamente el Proyecto, en el que el usuario se encuentra. No se como eliminarlo de la relación de usuarios. Muchas gracias por las respuestas. Un saludo -- 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.
Re: delete a field( many to many)
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 -- 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.
Re: delete a field( many to many)
Thank very much, but I don't know what's happen. I execute the next code and it's doing nothing : if request.POST.get('usuariosDelete','')!='': for i in request.POST.getlist('usuarios'): usuario=User.objects.get(id=i) datos.usuarios.remove(usuario) -- 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.
Delete a Field...
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.
Upload a file
My last question is whether anyone can tell me how to upload files of any kind, not just image. I've got the image, changing the picture of a user (in my program) but do not know how to upload files ... Thanks in advance. -- 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.
Automatic Submit
I get that it was not necessary to press the button "Save" for the sbmit. Do so without having to press the button(save or enter), that when you pass this sequence is executed automatically. Thanks -- 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.
Delete a many to many field who is in another table
Hi, I am finally going to finish the project started and where I end up liking this xD Django that the problem I have is the clearing of a field. I have the following tables. 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. -- 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.
Re: Delete a many to many field who is in another table
I try to make this using delete, remove.. Also I using too if request.POST.get('experimentosDelete','')!='': for i in request.POST.getlist('experimentosDelete'): exp=Experimentos.objects.get(proyecto=datos,id=i) exp.experimentos=[] ... I don't know how to make this.. Anyone who say me ??? Thanks a lot -- 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.