jazzband / django-floppyforms

Full control of form rendering in the templates.
http://django-floppyforms.readthedocs.org/
Other
837 stars 148 forks source link

Openlayers not loading in the template . #13

Closed ghost closed 13 years ago

ghost commented 13 years ago

I have an app called openmaps. The forms page looks like this

from django import forms from openmaps.models import Open_Layers from django.contrib.admin import widgets
import floppyforms as forms

class GeoForm(forms.Form): point = forms.gis.PointField() class PointWidget(forms.gis.PointWidget, forms.gis.BaseGMapWidget): pass

class OpenLayersAdmin(admin.OSMGeoAdmin): list_display = ('name','interestingness') list_filter = ('name','interestingness',) fieldsets = ( ('Location Attributes', {'fields': (('name','interestingness'))}), ('Editable Map View', {'fields': ('geometry',)}), )

# Default GeoDjango OpenLayers map options
 scrollable = False
 map_width = 700
 map_height = 325

admin.site.register(Open_Layers,OpenLayersAdmin)

The views look like this

from django.shortcuts import render_to_response from django.contrib.gis.shortcuts import render_to_kml from openmaps.models import *

def all_kml(request): locations = Open_Layers.objects.kml() return render_to_kml("gis/kml/placemarks.kml" , {'places' : locations})

def map_page(request): lcount = Open_Layers.objects.all().count() return render_to_response('maps.html', {'location_count' : lcount})

The template code is this

{# template.html #}

{{ form.media }}
{% csrf_token %} {{ form.as_p }}

But nothing shows up apart from the submit button . Any help would do .

brutasse commented 13 years ago

You're not passing a form instance to the view, your template needs a GeoForm in its context to display a map.

On Tue, Jun 14, 2011 at 10:17 AM, KasperaskyMe reply@reply.github.com wrote:

I have an app called openmaps. The forms page looks like this

from django import forms from openmaps.models import Open_Layers from django.contrib.admin import widgets import floppyforms as forms

class GeoForm(forms.Form):    point = forms.gis.PointField() class PointWidget(forms.gis.PointWidget, forms.gis.BaseGMapWidget):    pass

class OpenLayersAdmin(admin.OSMGeoAdmin):     list_display = ('name','interestingness')     list_filter = ('name','interestingness',)     fieldsets = (       ('Location Attributes', {'fields': (('name','interestingness'))}),       ('Editable Map View', {'fields': ('geometry',)}),     )

   # Default GeoDjango OpenLayers map options     scrollable = False     map_width = 700     map_height = 325 admin.site.register(Open_Layers,OpenLayersAdmin)

The  views look like this

from django.shortcuts import render_to_response from django.contrib.gis.shortcuts import render_to_kml from openmaps.models import  *

def all_kml(request):     locations  = Open_Layers.objects.kml()     return render_to_kml("gis/kml/placemarks.kml" , {'places' : locations})

def map_page(request):     lcount = Open_Layers.objects.all().count()     return render_to_response('maps.html', {'location_count' : lcount})

The template code is this

{# template.html #}

     {{ form.media }}        
     {% csrf_token %}      {{ form.as_p }}      

   
 

But nothing shows up apart from the submit button . Any help would do .

Reply to this email directly or view it on GitHub: https://github.com/brutasse/django-floppyforms/issues/13