Skip to content

Commit

Permalink
Merge ec50df3 into 3c7f761
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Mar 22, 2014
2 parents 3c7f761 + ec50df3 commit 504924f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Main purposes of having a python package for the Leaflet Javascript library :
* Control apparence and settings of maps from Django settings (e.g. at deployment) ;
* Reuse Leaflet map initialization code (e.g. local projections) ;

:note:

*django-leaflet* is compatible with `django-geojson <https://github.com/makinacorpus/django-geojson.git>`_ fields, which
allow handling geographic data without spatial database.

=======
INSTALL
Expand Down
11 changes: 9 additions & 2 deletions leaflet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ def formfield_for_dbfield(self, db_field, **kwargs):
Overloaded from ModelAdmin to set Leaflet widget
in form field init params.
"""
if isinstance(db_field, models.GeometryField) and (db_field.dim < 3 or
self.widget.supports_3d):
try:
from djgeojson.fields import GeoJSONField
except ImportError:
GeoJSONField = type(object)
is_geometry = isinstance(db_field, (models.GeometryField, GeoJSONField))
is_editable = is_geometry and (db_field.dim < 3 or
self.widget.supports_3d)

if is_editable:
kwargs.pop('request', None) # unsupported for form field
# Setting the widget with the newly defined widget.
kwargs['widget'] = self._get_map_widget(db_field)
Expand Down

0 comments on commit 504924f

Please sign in to comment.