From 5a038de1d52405e32602b238cb66b4c3f779fc7c Mon Sep 17 00:00:00 2001 From: Lars Butler Date: Mon, 5 Oct 2015 14:31:41 +0200 Subject: [PATCH] fields.ReferenceField: add integer values to `reverse_delete_rule` docs When I first tried to use the `reverse_delete_rule` feature of `ReferenceField`, I had to dig through the source code to find what the actual integer values were expected to be for DO_NOTHING, NULLIFY, CASCADE, DENY, and PULL (or at least, where these constants were defined so that I could import and use them). This patch adds the integer values for those constants (which are defined in mongoengine.queryset.base) to the docs so that users can easily choose the correct integer value. Note: A possible improvement on this change would be to include `mongoengine.queryset.base` module documentation in the generated docs, and then update the `ReferenceField` docs to link to the documentation of these constants (DO_NOTHING, NULLIFY, etc.). --- mongoengine/fields.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mongoengine/fields.py b/mongoengine/fields.py index f5899311..ad3c468b 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -863,12 +863,11 @@ class ReferenceField(BaseField): The options are: - * DO_NOTHING - don't do anything (default). - * NULLIFY - Updates the reference to null. - * CASCADE - Deletes the documents associated with the reference. - * DENY - Prevent the deletion of the reference object. - * PULL - Pull the reference from a :class:`~mongoengine.fields.ListField` - of references + * DO_NOTHING (0) - don't do anything (default). + * NULLIFY (1) - Updates the reference to null. + * CASCADE (2) - Deletes the documents associated with the reference. + * DENY (3) - Prevent the deletion of the reference object. + * PULL (4) - Pull the reference from a :class:`~mongoengine.fields.ListField` of references Alternative syntax for registering delete rules (useful when implementing bi-directional delete rules)