[Fixed]-Django-clever-selects TypeError with method is_valid()

1👍

For anyone else struggling with this issue, the following worked for me:

https://github.com/filipefigcorreia/django-clever-selects/commit/4f6da07bb9e880aaaa188297f5866bcbf9c6cab6

https://github.com/PragmaticMates/django-clever-selects/issues/6

Firstly in clever_selects/forms.py remove these lines

def __init__(self, language_code=None, *args, **kwargs):
self.language_code = language_code

add in

def __init__(self, *args, **kwargs):
self.language_code = kwargs.get('language_code', None)

in my app, forms.py, remove reverse_lazy

ajax_url=reverse_lazy('ajax_chained_subtypes') ==> ajax_url='/ajax/chained-subtypes/',

generates a bytes string problem, solved with:
clever_selects/forms.py line 97

field.choices = field.choices + json.loads(data.content) ==>
field.choices = field.choices + json.loads(data.content.decode("utf-8"))
👤Liz

Leave a comment