List Info

Thread: Newbie with generic views




Newbie with generic views
country flaguser name
United States
2007-08-30 13:59:52
Hi guys,

I'm trying to make a generic view to see some data, and I'm
having
some trouble.

I have some objects already in the database for the model
I'm trying
to generate this for.

Here's my urls.py:
#=====================
from django.conf.urls.defaults import *
from django.views.generic.list_detail import object_list
from mysite.myapp.models import Competitor

competitor_list_info = {
    'queryset' :   Competitor.objects.all(),
    'allow_empty': True,
	'template_name': 'competitor_list.html'
}

urlpatterns = patterns('',
         #snip#
	 (r'competitors/$', object_list, competitor_list_info)
	)
#=====================


And here's my simple template, competitor_list.html:
#=====================
{% extends "base.html" %}
{% block content %}
<ul class="objectlist">
{% for choice in field.choices %}
<li class="{% cycle odd,even %}"><a
href="{{ choice.url }}">{{ choice.label|escape
}}</a></li>
{% endfor %}
</ul>
{% endblock %}
#=====================

And I get no output...

What am I missing here? Can someone point me in the right
direction? I
can't seem to find any good documentation on writing
templates for
generic views.

Thanks,

Mike


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


Re: Newbie with generic views
country flaguser name
United States
2007-08-30 14:04:30
What is field.choices ? object_list doesn't pass _field_
variable to
context.
http://www
.djangoproject.com/documentation/generic_views/#django-views
-generic-list-detail-object-list
see Template context section


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


Re: Newbie with generic views
country flaguser name
United States
2007-08-30 14:05:30
Hmm...

Looks like I need to access the object_list context... that
seems to
be the first step that I'm missing...

I understand better somewhat already...although a link to
any
resources anyone might know of would be nice...

Thanks.

Mike

On Aug 30, 2:59 pm, Mike Atlas <mikeat...gmail.com> wrote:
> Hi guys,
>
> I'm trying to make a generic view to see some data, and
I'm having
> some trouble.
>
> I have some objects already in the database for the
model I'm trying
> to generate this for.
>
> Here's my urls.py:
> #=====================
> from django.conf.urls.defaults import *
> from django.views.generic.list_detail import
object_list
> from mysite.myapp.models import Competitor
>
> competitor_list_info = {
>     'queryset' :   Competitor.objects.all(),
>     'allow_empty': True,
>         'template_name': 'competitor_list.html'
>
> }
>
> urlpatterns = patterns('',
>          #snip#
>          (r'competitors/$', object_list,
competitor_list_info)
>         )
> #=====================
>
> And here's my simple template, competitor_list.html:
> #=====================
> {% extends "base.html" %}
> {% block content %}
> <ul class="objectlist">
> {% for choice in field.choices %}
> <li class="{% cycle odd,even %}"><a
> href="{{ choice.url }}">{{
choice.label|escape }}</a></li>
> {% endfor %}
> </ul>
> {% endblock %}
> #=====================
>
> And I get no output...
>
> What am I missing here? Can someone point me in the
right direction? I
> can't seem to find any good documentation on writing
templates for
> generic views.
>
> Thanks,
>
> Mike


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


Re: Newbie with generic views
country flaguser name
United States
2007-08-30 14:10:42
I'm on my way. Thanks...sometimes asking the right question
is the
best way to answer it for yourself :(

competitor_list.html
=========================
{% extends "base.html" %}
{% block content %}

<ul class="objectlist">
{% for object in object_list %}
<li><a href="{{ object.id }}">{{
object.fullname }}</a></li>
{% endfor %}
</ul>
{% endblock %}
=========================

On Aug 30, 3:04 pm, Alex Koshelev <daeva...gmail.com> wrote:
> What is field.choices ? object_list doesn't pass
_field_ variable to
> context.http://www.djangoproject.com/documentati
on/generic_views/#django-view...
> see Template context section


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


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )