theatlantic/django-select2-forms

Field rendering fails when URLs are not present

shezi opened this issue · 1 comments

I'm using your wonderful library for a simple ChoiceField. However, using it in this way:

from select2.fields import ChoiceField
class MyForm(forms.Form):
    something = ChoiceField(choices=('what', 'ever'))

will result in an exception in line 115 of widgets.py when rendering the widget in a template.

There are two problems with that line:

  1. This attribute should only be used when ajax is enabled.
  2. The reverse URL is only available when the supplied urls.py is added to the site's urls. This, however, isn't documented.

I'll prepare some edits that should resolve the problem. However, since I'm only using and testing the changes with a simple ChoiceField, don't trust them too far.

Thanks for the issue and pull request. I've merged it in.