Skip to content
This repository

KeyError 'slug' when trying to add a new page with the same slug as an already existing one #1484

kux opened this Issue October 18, 2012 · 5 comments

4 participants

Ioan Alexandru Cucu Patrick Lauber Iacopo Spalletti Gustavo
Ioan Alexandru Cucu
kux commented October 18, 2012

Reproduced this on django-cms 2.3.3

Steps to reproduce:
1. Create the first page with slug 'master' and publish it
2. Create the second page with the same slug ('master')
3. On the second page's change view tick 'Is published' and save the page


  • A nice error message that says that you can't have two published pages with the same slug


  • Status code 500, KeyError at /admin/cms/page/6/ 'slug'

File "/home/kux/workspace/src/other/django/django/core/handlers/" in get_response

  1. response = callback(request, *callback_args, **callback_kwargs) File "/home/kux/workspace/src/other/django/django/contrib/admin/" in wrapper
  2. return self.admin_site.admin_view(view)(*args, **kwargs) File "/home/kux/workspace/src/other/django/django/utils/" in _wrapped_view
  3. response = view_func(request, *args, **kwargs) File "/home/kux/workspace/src/other/django/django/views/decorators/" in _wrapped_view_func
  4. response = view_func(request, *args, **kwargs) File "/home/kux/workspace/src/other/django/django/contrib/admin/" in inner
  5. return view(request, *args, **kwargs) File "/home/kux/workspace/envs/contribute/local/lib/python2.7/site-packages/reversion/" in do_revision_context
  6. return func(*args, **kwargs) File "/home/kux/workspace/src/other/django-cms/cms/admin/" in change_view
  7. response = super(PageAdmin, self).change_view(request, object_id, extra_context=extra_context) File "/home/kux/workspace/src/other/django/django/utils/" in _wrapper
  8. return bound_func(*args, **kwargs) File "/home/kux/workspace/src/other/django/django/utils/" in _wrapped_view
  9. response = view_func(request, *args, **kwargs) File "/home/kux/workspace/src/other/django/django/utils/" in bound_func
  10. return func(self, *args2, **kwargs2) File "/home/kux/workspace/src/other/django/django/db/" in inner
  11. return func(*args, **kwargs) File "/home/kux/workspace/src/other/django/django/contrib/admin/" in change_view
  12. if form.is_valid(): File "/home/kux/workspace/src/other/django/django/forms/" in is_valid
  13. return self.is_bound and not bool(self.errors) File "/home/kux/workspace/src/other/django/django/forms/" in _get_errors
  14. self.full_clean() File "/home/kux/workspace/src/other/django/django/forms/" in full_clean
  15. self._clean_form() File "/home/kux/workspace/src/other/django/django/forms/" in _clean_form
  16. self.cleaned_data = self.clean() File "/home/kux/workspace/src/other/django-cms/cms/admin/" in clean
  17. cleaned_data = super(PageForm, self).clean() File "/home/kux/workspace/src/other/django-cms/cms/admin/" in clean
  18. title.slug = self.cleaned_data['slug']

Exception Type: KeyError at /admin/cms/page/6/
Exception Value: 'slug'

Ioan Alexandru Cucu
kux commented October 18, 2012

Note: If publishing two page with the same slug from the pages tree view, you do get a nice pop up dialog that says:

Page 'master' has the same url '/master/' as current page "master".

Ioan Alexandru Cucu
kux commented October 18, 2012

Wouldn't it be easier to just not let the user create two pages with the same slug? (look for duplicate slugs at page creation time rather than page publishing time)

Iacopo Spalletti

Thanks for your report.
I watched this happening a couple of time but I was too busy to check this out.
I opened PR #1485 that should fix this
It's actually already fixed in develop but I think should be ported to master.
As for checking this at creation or publishing time, the use case for late-check is that you can create a non published page with the same slug as a published page to prepare contents behind closes doors and then unpublish the old page and publish the new one when everything is ready

Ioan Alexandru Cucu
kux commented October 18, 2012

wow, that was fast :)

Patrick Lauber digi604 closed this October 19, 2012

I'm having an issue with slugs in child pages. Imagine I have a page called "Something" in the main tree with the slug "something", and another page named "Anything" with the slug "anything". This second page has a child page also called "Something" with the slug "something" again, that should result in an /anything/something/ url, and it was working on django-cms 2.3.5 but it's not working anymore on 2.4.1, i get an error saying i've already used that url (Page 'Something' has the same url 'something' as current page "Something"), but I'm trying to use it in a child page, that doesn't make sense to don't let me. Please get that fixed, it's the only thing stoping me from updating to 2.4.1 (latest release in the moment). Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.