codasus/django-location-field — pull request #6 by Kami (2013-04-27 05:49:19+00:00)
Title: Allow blank value for LocationField

## Environment details

Python version: 2.7.3
Django version: 1.5.1
Django Location Field version: 84718c64e039c4ca2974b62e220b60b6db74cf12 (latest master checkout)

## Problem

Currently the form explodes (both on validation and on rendering of the the field value) if you set field `blank` attribute to `True`, leave the value empty and save the model.

```python
return func(*args, **kwargs)
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 989, in add_view
if form.is_valid():
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/forms/forms.py", line 126, in is_valid
return self.is_bound and not bool(self.errors)
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/forms/forms.py", line 117, in _get_errors
self.full_clean()
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/forms/forms.py", line 272, in full_clean
self._clean_fields()
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/forms/forms.py", line 287, in _clean_fields
value = field.clean(value)
File "/home/vagrant/.virtualenvs/foo/src/location-field/location_field/forms.py", line 32, in clean
lat, lng = value.split(',')
ValueError: need more than 1 value to unpack
```

```python
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/template/debug.py", line 74, in render_node
return node.render(context)
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/template/debug.py", line 87, in render
output = force_text(output)
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/utils/encoding.py", line 99, in force_text
s = s.__unicode__()
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/forms/forms.py", line 411, in __str__
return self.as_widget()
File "/home/vagrant/.virtualenvs/foo/local/lib/python2.7/site-packages/django/forms/forms.py", line 458, in as_widget
return widget.render(name, self.value(), attrs=attrs)
File "/home/vagrant/.virtualenvs/foo/src/location-field/location_field/widgets.py", line 14, in render
lat, lng = value.split(',')
ValueError: need more than 1 value to unpack
```

This pull request fixes this and allows a blank value.