Russ-

Okay, one more question I changed the view around to make the code a
bit cleaner and use your suggestion as well as the render_to_response
shortcut I read about in the docs..


def view_items_tagged(request, tag):
    essay_list = Essay.objects.filter(tags=tag)
    return render_to_response('blog/tag_detail.html', {'essay_list':
essay_list, 'tag': tag})

Which works and the template loads, but there doesn't seem to be
anything in the object essay_list... In my template I have this code:

{% for essay in essay_list %}
.... display stuff .....
{% endfor %}

And nothing is displaying, that is the page loads fine and all the
auxilary content is there and {{ tag }} works fine, but essay_list is
empty, I think this has something to do with the context in render to
response, but I can't figure out what... the one thing I miss from php
is the print_r() method for debugging situations like this, is there a
python way to have essay_list get spit out something like
print_r(essay_list) would do in php...?

Anyway if you could point me in the right direction I'd be grateful


cheers
sng
<http://luxagraf.net>







On 10/23/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> On 10/24/06, luxagraf <[EMAIL PROTECTED]> wrote:
> >
> > Russ-
> >
> > ah. okay that makes sense. I was assuming that entry_set was a
> > contruct itself, but it's actually modelname_set...
>
> Yup.
>
> > So to make it purely abstract, things are working like this:
> >
> > response_obj = get_object_or_404(Model, param=value)
> > response_obj.modelname_set.all().select_related()
> >
> > and I can just append as many models as have M2M relations with the
> > first? Or is there a better way to do this?
>
> You appear to be on the right track. Is there a better way? It depends
> a bit on your application; however,
>
> model_list = ModelName.objects.filter(response=response_obj)
>
> might be slightly cleaner - it returns an empty list if there are no
> models for a response, rather than the 404 exception that your
> approach will yield (plus, it does it in a single query, rather than
> two queries)
>
> > Anyway thanks so much for your help, I've got it working now.
>
> No problems. Glad I could help.
>
> Yours,
> Russ Magee %-)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to