I have setup a django-treebeard model that has child nodes and what not. How do I now display this in my template? This is what I have so far.
My Models:
class SiteMapEntry(MP_Node):
name = models.CharField(max_length=100, null=False, blank=False)
url = models.CharField(max_length=1000, null=False, blank=False)
node_order_by = ['name']
class Meta:
verbose_name = "Sitemap Entry"
verbose_name_plural = "Sitemap Entries"
def __unicode__(self):
return ('%s - %s' % (self.name, self.url))
My Views:
from django.views.generic import ListView
class SiteMap(ListView):
model = SiteMapEntry
template_name = 'sitemaps.html'
My Template:
{% block content %}
<h1>Sitemap</h1>
<br /><br />
{% for url in object_list %}
<p>{{ url.name }}</p>
<p>{{ url.url }}</p>
{% endfor %}
{% endblock content %}
What this is doing right now, obviously is just listing the nodes and its children without any indenting. How do I list it like a tree in my template?