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
Copy file name to clipboardExpand all lines: docs/introduction/versioning_integration.rst
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,18 +163,18 @@ Whilst simple model structures should be fine using the `default_copy` function,
163
163
you will most likely need to implement a custom copy function if your :term:`content model <content model>`
164
164
does any of the following:
165
165
166
-
- Contains any one2one or m2m fields.
167
-
- Contains a generic foreign key.
168
-
- Contains a foreign key that relates to an
169
-
object that should be considered part of the version. For example
170
-
if you're versioning a poll object, you might consider the answers
171
-
in the poll as part of a version. If so, you will need to copy
172
-
the answer objects, not just the poll object. On the other hand if
173
-
a poll has an fk to a category model, you probably wouldn't consider
174
-
category as part of the version. In this case the default copy function
175
-
will take care of this.
176
-
- Other models have reverse relationships to your content model and
177
-
should be considered part of the version
166
+
- Contains any one2one or m2m fields (except one2one relationships through django CMS' :clas:``cms.extensions.models.BaseExtension``).
167
+
- Contains a generic foreign key
168
+
- Contains a foreign key that relates to an
169
+
object that should be considered part of the version. For example
170
+
if you're versioning a poll object, you might consider the answers
171
+
in the poll as part of a version. If so, you will need to copy
172
+
the answer objects, not just the poll object. On the other hand if
173
+
a poll has an fk to a category model, you probably wouldn't consider
174
+
category as part of the version. In this case the default copy function
175
+
will take care of this.
176
+
- Other models have reverse relationships to your content model and
177
+
should be considered part of the version
178
178
179
179
So let's get back to our example and complicate the model structure a little. Let's say our
180
180
`blog` app supports the use of polls in posts and also our posts can be categorized.
@@ -215,11 +215,11 @@ Now our `blog/models.py` now looks like this:
215
215
If we were using the `default_copy` function on this model structure, versioning wouldn't necessarily do what you expect.
216
216
Let's take a scenario like this:
217
217
218
-
1. A Post object has 2 versions - `version #1` which is archived and `version #2` which is published.
219
-
2. We revert to `version #1` which creates a draft `version #3`.
220
-
3. The PostContent data in `version #3` is a copy of what was in `version #1` (the version we reverted to), but the Poll and Answer data is what was there at the time of `version #2` (the latest version).
221
-
4. We edit both the PostContent, Poll and Answer data on `version #3`.
222
-
5. The PostContent data is now different in all three versions. However, the poll data is the same in all three versions. This means that the data edit we did on `version #3` (a draft) to Poll and Answer objects is now being displayed on the published site (`version #2` is published).
218
+
1. A Post object has 2 versions - `version #1` which is archived and `version #2` which is published.
219
+
2. We revert to `version #1` which creates a draft `version #3`.
220
+
3. The PostContent data in `version #3` is a copy of what was in `version #1` (the version we reverted to), but the Poll and Answer data is what was there at the time of `version #2` (the latest version).
221
+
4. We edit both the PostContent, Poll and Answer data on `version #3`.
222
+
5. The PostContent data is now different in all three versions. However, the poll data is the same in all three versions. This means that the data edit we did on `version #3` (a draft) to Poll and Answer objects is now being displayed on the published site (`version #2` is published).
223
223
224
224
This is probably not how one would want things to work in this scenario, so to fix it, we need to implement a custom :term:`copy function <copy function>` like so:
0 commit comments