Database Reference
In-Depth Information
# media files
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$',
'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT}))
2. Openthe views.py fileunder chp09/wildlife/sightings andaddthe
followingcode.The home viewwillreturnthehomepageofyourapplication,
withthelistofsightingsandtheLeafletmap.The sighting layerinthemap
will display the GeoJSON response given by the get_geojson view:
from django.shortcuts import
render_to_response
from django.http import HttpResponse
from vectorformats.Formats import Django,
GeoJSON
from models import Sighting
def home(request):
"""
Display the home page with the list and
a map of the sightings.
"""
sightings = Sighting.objects.all()
return render_to_response("sightings/
home.html", {'sightings' : sightings})
def get_geojson(request):
"""
Get geojson (needed by the map) for all
of the sightings.
"""
sightings = Sighting.objects.all()
djf =
Django.Django(geodjango='geometry',
properties=['animal_name',
'animal_image_url', 'description',
'rate', 'date_formatted',
Search WWH ::




Custom Search