From 65d6f8c01817ce7a7c104391db087f9a90f91269 Mon Sep 17 00:00:00 2001 From: Frederik Creemers Date: Tue, 2 Jun 2015 12:35:25 +0200 Subject: [PATCH 1/2] Solution for documentation issue #1003 Solution for documentation issue #1003. The explanation about reverse_delete_rule was a bit mixed up. --- docs/guide/defining-documents.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/defining-documents.rst b/docs/guide/defining-documents.rst index 79332493..62676983 100644 --- a/docs/guide/defining-documents.rst +++ b/docs/guide/defining-documents.rst @@ -315,9 +315,9 @@ reference with a delete rule specification. A delete rule is specified by supplying the :attr:`reverse_delete_rule` attributes on the :class:`ReferenceField` definition, like this:: - class Employee(Document): + class ProfilePage(Document): ... - profile_page = ReferenceField('ProfilePage', reverse_delete_rule=mongoengine.NULLIFY) + profile_page = ReferenceField('Employee', reverse_delete_rule=mongoengine.CASCADE) The declaration in this example means that when an :class:`Employee` object is removed, the :class:`ProfilePage` that belongs to that employee is removed as From 91aa4586e2a7684ff3a73f21a032e1702c04dbc5 Mon Sep 17 00:00:00 2001 From: Frederik Creemers Date: Thu, 4 Jun 2015 22:38:11 +0200 Subject: [PATCH 2/2] Fixes after code review --- docs/guide/defining-documents.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/defining-documents.rst b/docs/guide/defining-documents.rst index 62676983..4d81b054 100644 --- a/docs/guide/defining-documents.rst +++ b/docs/guide/defining-documents.rst @@ -317,10 +317,10 @@ supplying the :attr:`reverse_delete_rule` attributes on the class ProfilePage(Document): ... - profile_page = ReferenceField('Employee', reverse_delete_rule=mongoengine.CASCADE) + employee = ReferenceField('Employee', reverse_delete_rule=mongoengine.CASCADE) The declaration in this example means that when an :class:`Employee` object is -removed, the :class:`ProfilePage` that belongs to that employee is removed as +removed, the :class:`ProfilePage` that references that employee is removed as well. If a whole batch of employees is removed, all profile pages that are linked are removed as well.