I am new to django and created an application that is not much different from the survey site described in the tutorial. On the website I get:
Exception Type: TemplateSyntaxError
Exception Value:
Caught TypeError while rendering: 'Manager' object is not iterable
Exception Location: /usr/lib/python2.7/dist-packages/django/template/defaulttags.py in render, line 190
pointing to a template indicating a line of error line 4 (Caught TypeError when rendering: the Manager object is not iterable):
test
2 {% if clips %}
3 <ul>
4 {% for aclip in clips %}
5 <li><a href="/annotate/{{ aclip.id }}/">{{ aclip.name }}</a></li>
6 {% endfor %}
7 </ul>
8 {% else %}
9 <p>No clips are available.</p>
10 {% endif %}
Here is the clip object:
class Clip(models.Model):
def __unicode__(self):
return self.name
name = models.CharField(max_length=30)
url = models.CharField(max_length=200)
And the view code:
def index(request):
mylist = []
latest_clip_list = Clip.objects.all()
print latest_clip_list
return render_to_response('annotateVideos/index2.html', {'clips': latest_clip_list})
When I run this code from a control shell, py is no exception:
In [2]: from annotateVideos import views
In [3]: f = views.index("")
[{'id': 6L, 'name': u'segment 6000'}]
In [4]: f.content
Out[4]: 'test\n\n <ul>\n \n <li><a href="/annotate//"></a></li>\n \n </ul>\n'
Any ideas? It's hard for me to debug, as the code seems to work with the shell, but not on the web server.
Thanks Raphael
source
share