Sorry if my question sounds stupid as i am new to Django.
I have a view in Django like this :
def myview(request):
list = Ref.objects.all()
return render_to_response('annonces.html', {'list': list} ,RequestContext(request))
Ref is a small sqlite database where i store things scraped from the web.
In my django template, i want to loop on a field of my list object (hurl) which contains a list of links (images) in order to show it on my web page. I've tried this :
{% for value in list %}
{% for link in value.hurl %}
<li><img src="{{ link }}"></li>
{% endfor %}
{% endfor %}
Unfortunately, it doesn't work. The object list convert everything to string so the loop in my template create a line for each character in the field hurl.
Would you know how i can get my object to render hurl as a list instead of a string ?
Here is an example of value.hurl :
u"['http://3.visuels.poliris.com/thumbnails/3/3/6/5/3365ddc7-3f27.jpg', 'http://1.visuels.poliris.com/thumbnails/1/2/b/6/12b6c286-372f.jpg', 'http://b.visuels.poliris.com/thumbnails/b/4/f/3/b4f32a1c-3159.jpg']"
Here is the model. Not sure if URLField is correct for hurl.
class Ref(models.Model):
ref = models.IntegerField(max_length=10, primary_key='True')
title = models.CharField(max_length=500)
hurl = models.URLField()
url = models.URLField()
prix = models.CharField(max_length=500)
Thanks Gilles
hurlfield?