0
votes

I have 3 Document classes:

class Policy(Document):
    name = StringField(required=True)

class Group(Documet):
    # ...
    policy = ReferenceField('Policy', db_field='policy_id')

class Item(Document):
    foo = StringField()
    group = ReferenceField(Group, db_field='group_id')

Now - when I set Item -> Group -> Policy relationship, all is fine until I update the policy.

I'm doing it in a code that eventually changes .name in a Policy type object (will call it x) and run x.save()

The DB in the correct policy gets updated perfectly, none of the ObjectIds change (nor the ReferenceField object)

But still:

item = Item.objects.get(foo='needed_item')
policy = item.group.policy

policy.name contains the old value (as if it was not updated at all)

Do ReferenceField has a manual "refresh" I need to run?

1

1 Answers

0
votes

If you have the instance stored in memory then you need to call the reload method on the document.