MongoEngine / MongoEngine/mongoengine
Unable to set reverse_delte_rule to GenericReferenceField. AttributeError: 'GenericReferenceField' object has no attribute 'document_type'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported Movie model with GenericReferenceField(reverse_delete_rule=db.CASCADE), then compare GenericReferenceField with ReferenceField to trace where document_type is expected. Done means the reported AttributeError is resolved and the reverse-delete behavior is covered by a regression test; the issue names no specific files or existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100