Question

I am using Django with Neo4j as DB (nep4django).

I have a primitive template to display the list of 3 cities, like I do it with Django python shell:

In [8]: from mydb.models import Place

In [9]: cities = Place.objects.all()

In [10]: for city in cities:
   ....:     print city.name
   ....:     
Paris
Zurich
London

my template cities.html:

<!DOCTYPE html>
<html><head><title>Cities</title></head>
    <body>
        <h1>Cities</h1>
        <ul>
            {% for city in cities %}
            <li>{{ city.name }}</li>
            {% endfor %}
        </ul>
    </body></html>

On my http://localhost:8000/cities/ page I don't get any error, but the only thing that is displayed is Cities. So, I have title and h1 displayed, but not the ul part, where I actually use my DB. How can I fix this?

views.py file:

from django.shortcuts import render_to_response
from models import Place

def show_places(request):
   cities = Place.objects.all()
   return render_to_response('cities.html', {'List of cities': cities})

urls.py file:

from django.conf.urls import patterns, include, url
from neo4django import admin
from mydb.views import show_places

admin.autodiscover()

urlpatterns = patterns('',
    (r'^admin/', include(admin.site.urls)),
    (r'^cities/', show_places),
)
Was it helpful?

Solution

Change List of cities by cities. You are asigning that variable name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top