django generic view not recieving an object (template issue?)
Posted
by Kirby
on Stack Overflow
See other posts from Stack Overflow
or by Kirby
Published on 2010-04-08T17:24:19Z
Indexed on
2010/04/08
17:33 UTC
Read the original article
Hit count: 316
django
|django-templates
My Model
class Player(models.Model):
player_name = models.CharField(max_length=50)
player_email = models.CharField(max_length=50)
def __unicode__(self):
return self.player_name
My Root urls.py
urlpatterns = patterns('',
(r'^kroster/', include('djangosite.kroster.urls')),
(r'^admin/(.*)', admin.site.root),
)
My kroster urls.py
from djangosite.kroster.models import Player
info_dict = {
'queryset': Player.objects.all(),
}
urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list', info_dict),
(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
)
My player_list.html template
<h1>Player List</h1>
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<ul>
{% for player in object.player_set.all %}
<li id="{{ player.id }}">{{ forloop.counter }} .) {{ player }}</li>
{% endfor %}
</ul>
Sadly my template output is this.
<h1>Player List</h1>
<ul>
</ul>
Apologies if this is a stupid mistake. It has to be something wrong w/ my template.
© Stack Overflow or respective owner