New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Model PageUrl should add constraint unique_together #7838
Labels
Comments
@jrief Great work finding this!!!! |
Another note on this: Slugs currently are not validated against having uppercase letters. This is a problem, because I would suggest to add an explicit method Shall I create a pull request for this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Each CMS
Page
can have onePageUrl
object per language. If there are more than that, aMultipleObjectsReturned
-exception may be raised.Steps to reproduce
The
PageUrl
-object for the home page now has two entries in the database. Reason is thisdjango-cms/cms/models/pagemodel.py
Lines 292 to 296 in 21d6a6d
code snippet. Here
new_path
is a functional expression containingConcat(ConcatPair(Value('parent_slug'), ConcatPair(Value('/'), F(slug))))
. Since the resultingpath
field of the home page must be an empty string the above query can't work.Alternative reproduction
Now we get two objects of
PageUrl
with the samelanguage
and the samepath
entry for different pages. This in my opinion is inconsistent.I therefore strongly recommend to add
unique_together = [['path', 'language'], ['page', 'language']]
to theMeta
-class of thePageUrl
-class.In my setup I already did this. This is how I found out about the two errors reported before. Otherwise I rarely ran into the problem of hitting a
MultipleObjectsReturned
-exception, whose real cause then of course is much harder to detect.Do you want to help fix this issue?
I already patched this locally and would like to know if that proposed model change makes sense.
The text was updated successfully, but these errors were encountered: