I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that.
Can someone please suggest how that can be done?
Thanks in advance.
Two possible solutions:
Check if the reference still exists, before you access it:
if not obj.reference:
# Referenced entity was deleted
When you delete a model object that may be referenced, query all models that might reference it, and set their reference property to None.