On Monday, January 3, 2011 9:25:00 PM UTC, robos85 wrote: > > I use modelform. All works fine. Validation is ok and I want to save my > form. Before saving I need to populate user_id into my modelform so i make > something like this: > if form.is_valid(): > > obj = form.save(commit=False) > > obj.user = request.user > obj.save() > > It seems to be ok. Form is saved to DB BUT!: I use > categories = models.ManyToManyField(Category) > > When I use the method above - categories aren't saved into DB :( > When I do form.save() - categories are added but User object not :( > > Am I something missing? >
This is explicitly documented here: http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#the-save-method (third paragraph after the green box). -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

