On Tuesday, 6 March 2012 19:14:55 UTC, angel wrote:
>
> I am new to django and doing my course project. I am searching for a 
> solution for iterating  JSON dictionary  in html page. My django view 
> is the following: 
>
> def do_GET(self, offset): 
>         data=get_object_or_404(NewAuction,pk=offset) 
>         context=serializers.serialize("json",[data]) 
>         data1=json.dumps(context) 
>         return render_to_response("index.html",{"data1":data1}) 
> NewAuction is the model and offset is the particular id. 
>
> Now I want to display the dictionary using the variable data1 in 
> html.I use {{data1}} for this. but I got the following 
>
> "[{\"pk\": 5, \"model\": \"Auction.newauction\", \"fields\": 
> {\"username\": 1, \"category\": \"furniture\", \"description\": \"Made 
> of Wood\", \"end_date\": \"2012-05-01 11:00:00\", \"start_price\": 
> \"100\", \"title\": \"Table\", \"start_date\": \"2012-03-04 
> 11:24:11\"}}]" 
>
> How I can iterate it for displaying like 
>
> category:furniture 
> description:Made of wood 
> .................................... 
> ...................................... 
> like this. 
>
> Is anyone can help me? 
>
>
>
>
You're converting to JSON twice. `serializers.serialize('json', foo)` 
already converts the data to JSON. There's no need to call `json.dumps` on 
the result.
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/uFjDAUEqwhoJ.
To post to this group, send email to django-users@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