theatlantic / django-select2-forms

Django form fields using the Select2 jQuery plugin
Other
82 stars 30 forks source link

Field rendering fails when URLs are not present #1

Closed shezi closed 11 years ago

shezi commented 11 years ago

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.

fdintino commented 11 years ago

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