You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
chavus
changed the title
Unable to define reverse_delte_rule to GenericReferenceField. AttributeError: 'GenericReferenceField' object has no attribute 'document_type'
Unable to set reverse_delte_rule to GenericReferenceField. AttributeError: 'GenericReferenceField' object has no attribute 'document_type'
Apr 23, 2020
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.
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.
The text was updated successfully, but these errors were encountered: