On 03/06/2012 09:52 PM, shiji bijo wrote:
ok I have removed the json.dumps() now the view is
def do_GET(self, offset):
data=get_object_or_404(NewAuction,pk=offset)
context=serializers.serialize("json",[data])
return render_to_response("index.html",{"context":context})
and my index.html is
{% extends 'base.html' %}
{% block contentblock %}
{{ context }}
{% endblock %}
and it is printing like
[{"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"}}]
But how I can iterate the fields in html. please help me
--
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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
You are trying to display a json object as html I think this won't work
(I'm not a django expert). If using jsonn is a must, I would put the
context variable from your template into a hidden div or a CDATA or
whatever not displayed, and then you can use javascript when the
document is loaded. Retrieve the element, parse the data as json and in
creating the DOM elements you need should be trivial, specially if you
use jQuery or some other javascript framework.
HTH
--
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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.