Unable to set reverse_delte_rule to GenericReferenceField. AttributeError: 'GenericReferenceField' object has no attribute 'document_type'
I get the following error when trying to add "reverse_delete_rule=db.CASCADE" to a GenericReferenceField:
AttributeError: 'GenericReferenceField' object has no attribute 'document_type'
This is my code:
`from database.db import db
class Movie(db.DynamicDocument): name = db.StringField(required=True, unique=True) casts = db.ListField(db.StringField) genres = db.ListField(db.StringField) directors = db.GenericReferenceField(reverse_delete_rule=db.CASCADE) `
This is the error: AttributeError: 'GenericReferenceField' object has no attribute 'document_type'
My understanding is that GenericReferenceField inherits ReferenceField attributes.
its not working ,u can use numbers 0.,1,2,3,4
GenericReferenceField does not inherit from ReferenceField. Currently MongoEngine does not support reverse delete rules for GenericReferenceField.
This could be fixed in multiple ways, either by having GenericReferenceField check every defined Document upon deletion (expensive and honestly not sure if this feature should be given to users given the performance concerns) or by allowing reverse delete rules when the GenericReferenceField defines a set of choices for documents it can reference, then checking that smaller set of document upon delete.