On Dec 11, 3:33 am, Mark Schuuring <mj.schuur...@gmail.com> wrote:
> Hey Daniel,
> First of all thanks a lot for your response. You understood it right
> that i just want to split up the columns by the blog id so the
> defintion of blogs_one and blogs_two was really helpful, thanks. So in
> the shell i found out the blogs_x sort the posts. But unfortunately i
> can't get it straight to let this work in the template. I worked
> through thehttp://docs.djangoproject.com/en/dev/ref/templates/builtins/
> page and used several conditioners (for / if ) which all don't work or
> I applied them wrong. For now I have this

I'm afraid I'm still not able to understand your problem. What didn't
work? What result did you get? What were you expecting? What errors
did it show?

I do have some general comments on your code, below:

> ************************** views.py *********************
> def blogs(request, username=None, template_name="blog/blogs.html"):
>     blogs_one = Post.objects.filter(blog__id=1)
>     global blogs_one
>
>     blogs_two = Post.objects.filter(blog__id=2)
>     global blogs_two

What are the global statements for? I can't see any reason for them.

>
>     if username is not None:
>
>         user = get_object_or_404(User, username=username.lower())
>         blogs_one = Post.objects.filter(author=user, blog__id=1)
>         blogs_two = Post.objects.filter(author=user, blog__id=2)


Better to filter the querysets you already have:
           blogs_one = blogs_one.filter(author=user)
           blogs_two = blogs_two.filter(author=user)



>     return render_to_response(template_name, {
>         "blogs_one": blogs_one,
>         "blogs_two": blogs_two,
>     }, context_instance=RequestContext(request))
>



> ********************** Template ***********************
>
>     {% if blogs %}
>         <p>{% trans "These are blog posts from everyone:" %}</p>
>
> <table>
> <tr>
> <td>
>       {% autopaginate blogs_one %}
>
>             {% for blog_post in blogs %}
>                 {% show_blog_post blog_post %}
>             {% endfor %}
>         {% paginate %}
> </td>
> <td>
>       {% autopaginate blogs_two %}
>
>             {% for blog_post in blogs %}
>                 {% show_blog_post blog_post %}
>             {% endfor %}
>         {% paginate %}
> </td>
> </tr>
> </table>
>
>     {% else %}
>         {% trans "No blog posts yet." %}
>     {% endif %}

This is no help as I have no idea what the {% autopaginate %} and {%
show_blog_post %} tags do. Do they put a 'blogs' object in the
context? If not then surely your for loops should reference blogs_one
and blogs_two, not just blogs.
--
DR.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.


Reply via email to