Setting a GenericForeignKey results to a FieldNotFoundError

5 views
Skip to first unread message

Salvatore Iovene

unread,
Jun 10, 2012, 10:40:27 AM6/10/12
to django...@googlegroups.com
Hi,
I'm using django-reviews <https://github.com/danawoodman/django-reviews/> in my site.

Sometimes, reviewed items will be merged by an admin, so, whenever I merge Item B to Item A, I also move all the reviews of B to A.

I do it this way:

ReviewedItem.objects.filter(gear = slave).update(object_id = master.id)

Apparently this is not enough, though, because the content_object member of ReviewedItem will be None after that.

But if I change the line above to include a "content_object = master" in the .update() statement, Django will complain about FieldNotFoundError.

I suppose there's some magic to the GenericForeignKey that I didn't understand.


Can anyone tell me how to properly update an instance so it refers to a different item?

Thank you!
Reply all
Reply to author
Forward
0 new messages