Re: Why is this view not displaying data?

2009-09-27 Thread jeffself


Thanks Karen!  That did the trick.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why is this view not displaying data?

2009-09-27 Thread Karen Tracey
On Sun, Sep 27, 2009 at 8:41 PM, jeffself  wrote:

>
> Here's my url.py:
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('Rankings.college.views',
>url(r'^rankings/division/(\w+)/$', 'rankings_by_league'),
> )
>
> views.py
>
> def rankings_by_league(request, league):
>try:
>league = League.objects.get(slug__iexact=league)
>except League.DoesNotExist:
>raise Http404
>
>return list_detail.object_list(
>request,
>queryset = SchoolSeason.objects.all(),
>template_name = "college/rankings_by_league.html",
>template_object_name = "rankings",
>extra_context = {"league": league}
>)
>
> rankings_by_league.html
> {% extends "base.html" %}
>
> {% block title %}My rankings {% endblock %}
>
> {% block content %}
>
> 2009 {{ league.league_name }} Rankings
>
> 
>{% for ranking in rankings %}
>{{ ranking.school.school_name}} {{ ranking.wins}}
> {{ ranking.losses}} {{ ranking.rating}}
>{% endfor %}
> 
>
> {% endblock %}
>
> I've spent my entire Sunday looking at this and can't figure it out.
> Only thing that displays is the  tag.
>

Doc here:

http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-list-detail-object-list

states that _list will be appended to the value of your template_object_name
to create the variable name used in the context.  So try iterating through
rankings_list.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Why is this view not displaying data?

2009-09-27 Thread jeffself

Here's my url.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('Rankings.college.views',
url(r'^rankings/division/(\w+)/$', 'rankings_by_league'),
)

views.py

def rankings_by_league(request, league):
try:
league = League.objects.get(slug__iexact=league)
except League.DoesNotExist:
raise Http404

return list_detail.object_list(
request,
queryset = SchoolSeason.objects.all(),
template_name = "college/rankings_by_league.html",
template_object_name = "rankings",
extra_context = {"league": league}
)

rankings_by_league.html
{% extends "base.html" %}

{% block title %}My rankings {% endblock %}

{% block content %}

2009 {{ league.league_name }} Rankings


{% for ranking in rankings %}
{{ ranking.school.school_name}} {{ ranking.wins}}
{{ ranking.losses}} {{ ranking.rating}}
{% endfor %}


{% endblock %}

I've spent my entire Sunday looking at this and can't figure it out.
Only thing that displays is the  tag.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---