On Jan 5, 5:16 pm, pjmorse <flashesofpa...@gmail.com> wrote: > I recently picked up a Django project from another developer, and I > seem to have introduced an annoying bug. > > It's a multi-language site: US, UK, DE. (Why US and UK are considered > different languages is organizational politics beyond the scope of my > work.) When a "news article" is created, its body text is used to > create three "news translations" (NewsTrans object), one for each > language. > > This is done by looping over the list of languages and saving a > NewsTrans in each language. The source language is marked as already > translated, the other two are not (that is, they still need > translating). > > The problem is that this is done with ns.save() (where ns is a > NewsTransForm with the submitted data), and what's actually happening > is that one NewsTrans is created, then it is updated twice, ending in > the third language. > > I thought I could fix this with ns.save(force_insert=True) but that > throws errors instead: "save() got an unexpected keyword argument > 'force_insert'". > > The site is using Django 1.0.2. > > I'm pretty much wedged on this now, so any pointers would be greatly > welcomed.
Some code would have been helpful. I note that force_insert is an argument to the **model** save method, not the form one, so that's perhaps your issue. For the form, perhaps you can do newobj1 = form.save(commit=False) and repeat newobj2 and newobj3, then save them all individually. -- DR.
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.