Search code examples
djangodjango-cms

DjangoCMS copy site slug


we're using djangocms and have german and english pages. Now the slugs for both pages need to be the same. Is there a way to copy the slugs of all german pages to all the english ones without going into the site settings and copy-pasting the german slug to the english slug?

I was going for something like

manage.py cms copy lang --from-lang=de --to-lang=en --verbosity=2 --skip-content

but I haven't tried it yet. Thank you for any help.


Solution

  • The copy management command copies the entire contents of pages / sites, it is not limited to just the settings. https://github.com/divio/django-cms/blob/develop/docs/reference/cli.rst#cms-copy

    You could create your own management command by copying the entire command from the cms and modifying it to suit your needs, this would be located in your own project.

    All you want to do is to get the DE title and set the slug:

    https://github.com/divio/django-cms/blob/develop/cms/management/commands/subcommands/copy.py#L56

    This is how the CMS does this internally when copying a page: https://github.com/divio/django-cms/blob/develop/cms/models/pagemodel.py#L700