Saturday, May 26, 2012

Re: how to do this?

On Sat, 2012-05-26 at 00:17 -0700, doniyor wrote:
> hey guys, i need again a small help. i want to create so many htmls as the
> number of objects of my model in db. i am trying, but it is stopping after
> the first creation, because i am doing render_to_response and after the
> first render_to_response it is not going to the second loop, because i
> "return",
>
> how is it possible?
>
> this is my code.
>
> for p in Produkt.objects.all():
> col = p.arg1
> row = p.arg2
> t = Template('<p> test </p>')
> c = Context({'col': col, 'row':row})
> html = t.render(c)
> return render_to_response('book.html', {'html': html},
> context_instance=RequestContext(request))
> return render_to_response('book.html', {'titel': titel},
> context_instance=RequestContext(request))
>
> thanks many
>

possibly you need this:
in your view:
products = Product.objects.all()

and in your template:

{% for p in products %}
{{p.arg1}} {{p.arg2}}
{% endfor %}
--
regards
Kenneth Gonsalves

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate