Log in

slugify() got an unexpected keyword argument 'ok'

  • 1
  • 26 May '16

Hi. I was playing around with the forum and suddenly, when I tried to create a new thread, following error occurred (see below).
But I'm quite sure I didn't change anything in the code :)
The error disappears when I change ST_UNICODE_SLUGS from True to False, according to the code unicode_slugs works only in Django 1.9 and my version is 1.8, but why is it worked earlier :)

*TypeError at /de/qanda/topic/publish/

slugify() got an unexpected keyword argument 'ok'

Request Method: POST
Request URL: http://www.dev.dev:4000/de/qanda/topic/publish/
Django Version: 1.8.13
Exception Type: TypeError
Exception Value:

slugify() got an unexpected keyword argument 'ok'

Exception Location: /home/vagrant/dev/lib/python3.4/site-packages/spirit/core/utils/models.py in pre_save, line 46
Python Executable: /home/vagrant/dev/bin/python
Python Version: 3.4.4
Python Path:

['/home/vagrant/dev/development',
'/home/vagrant/dev/src/django-polls',
'/home/vagrant/dev/lib/python34.zip',
'/home/vagrant/dev/lib/python3.4',
'/home/vagrant/dev/lib/python3.4/plat-linux',
'/home/vagrant/dev/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4',
'/usr/local/lib/python3.4/plat-linux',
'/home/vagrant/dev/lib/python3.4/site-packages']

Server time: Do, 26 Mai 2016 08:23:54 +0000*

nitelyEsteban Castro Borsani
  • 3
  • 27 May '16

Spirit only supports Django 1.8, it won't work with Django 1.9.

slugify() got an unexpected keyword argument 'ok'

To support unicode slugs, Spirit depends on unicode-slugify which has not been updated in a year, so the slugify() call to this library should accept that parameter. My guess is you either have an old version of unicode-slugify (very unlikely) or you have a package/library conflicting with it (ie: the library is called slugify), so when Spirit tries to import slugify, it's actually importing this other library instead of unicode-slugify.

But I'm quite sure I didn't change anything in the code :)

Or... you did?.

The error disappears when I change ST_UNICODE_SLUGS from True to False

unicode-slugify is not called when that settings is setted to False.

nitelyEsteban Castro Borsani
  • 27 May '16

This topic has been moved.

  • 1
  • 30 May '16

I've just show this peace of code and thought aha it needs to be set to true for 1.9 (i know stupid :))

TODO: Django 1.9 will support unicode slugs

    if settings.ST_UNICODE_SLUGS:
        # TODO: mark as safe?
        slug = unicode_slugify(smart_text(value), ok='-')
    else:
        slug = slugify(smart_text(value))

As I wrote I didn't change anything in the code, but I've installed some plugins for django cms and I suspect that this causes the conflicts. Need to check it.
Thanks @nitely

Reply