>>>     def clone_creatives(self, src_theme_id):
>>>         themeA = Theme.objects.get(id=src_theme_id)
>>>         self.unit_set.all().delete()
>>>         for u in themeA.unit_set.all():
>>>             <http://u.id>u.id = None
>>>             u.theme_id = <http://self.id>self.id

This line is your problem. You can use foo_id fields as getter properties
if you don't want to trigger the FK look-up, but I don't believe they work
as setters. Instead use:
u.theme = self.id

If you specify the integer (or more accurately, the raw PK value of the
related object) on an FK field, Django will use that value.

Honestly, though, doing that doesn't save you anything and makes your code
more complex to figure out, since you already have a fully populated Theme
object in self available in this case.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWXSZ2GUsxmQLEoiDd-n3%2BaExW75XtgW%2BwS-PymvVsBsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to