Re: Saving forms with ManyToMany relationships

2014-04-09 Thread Camilo Torres
Hello, update your models.py: class Course(models.Model): name = models.TextField() students = models.ManyToManyField(Student, related_name='courses') *users = models.ManyToManyField(User)* Update your views.py: def create_item(request): if request.method == 'POST': for

Re: Saving forms with ManyToMany relationships

2014-04-08 Thread Jason S
Hi, Thanks very much, I can now save the item.component and item.category many to many fields. However I can't save the user as request.user and it still boils down to not quite understanding how to specify a field value to be saved. I've tried variations of my original code and suggestions onli

Re: Saving forms with ManyToMany relationships

2014-04-07 Thread Camilo Torres
Hello, This works for me, saving the related objects in the many to many relationship. You can start from there to build yours: models.py: class Student(models.Model): name = models.TextField() class Course(models.Model): name = models.TextField() students = models.ManyToManyField

Re: Saving forms with ManyToMany relationships

2014-04-07 Thread Jason S
Hi Camilo, I really appreciate your response. I had another go at this last night, particularly trying to use the add(component()) snippet. To respond to your notes: 1. I simplified and used a find-replace to replace the model names which is likely why it dosn't compile, sorry about that. Mine c

Re: Saving forms with ManyToMany relationships

2014-04-06 Thread Camilo Torres
On Saturday, April 5, 2014 10:12:36 PM UTC-4:30, Jason S wrote: > > I've seen quite a few examples showing various ways to create a form using > manytomany relationships and save the data, but i'm still missing a key > piece of the puzzle. > I've created a form and it "works", meaning the form cr

Saving forms with ManyToMany relationships

2014-04-05 Thread Jason S
Hi, I've seen quite a few examples showing various ways to create a form using manytomany relationships and save the data, but i'm still missing a key piece of the puzzle. I've created a form and it "works", meaning the form creates a new Item object and associates the user. However i'm not sure