On Fri, Nov 7, 2008 at 12:17 AM, Darthmahon <[EMAIL PROTECTED]> wrote:
>
> Hi guys, I'll give both a try tomorrow when I am near my dev box
> again. Can't really do it in the template as I just want to dump out
> JSON only, but I'll give them both a go :)
I use templates for all my JSON output, m
Hi guys, I'll give both a try tomorrow when I am near my dev box
again. Can't really do it in the template as I just want to dump out
JSON only, but I'll give them both a go :)
Cheers,
Chris
On Nov 6, 9:51 am, "Dj Gilcrease" <[EMAIL PROTECTED]> wrote:
> If you dont mind using the template system
If you dont mind using the template system I think this should produce
the results you are looking for
[{% for event in events %}
{% ifchanged event.date %}{ 'date' : '{{ event.date }}',
'dayEvents' : [{% endif %}
{ 'title' : '{{ event.title }}', 'location' : '{{
event.location
It's strange. I've just try this example and it is good:
In [1]: results = []
In [2]: results.append( { 'date' : '2008-11-04 00:00:00', 'dayEvents' :
...: [ { 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, {
'title' :
...: 'Event 2', 'location' : '1', 'id' : '2' } ] } )
Hey Alex,
I tried this hard coded JSON the other day:
results = []
results.append( { 'date' : '2008-11-04 00:00:00', 'dayEvents' :
[ { 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, { 'title' :
'Event 2', 'location' : '1', 'id' : '2' } ] } )
But I got an error when I did this (can't remem
With simplejson module (that is part of django distribution) you can covert
to JSON any python objects. So create data structure you need and pass it to
simplejson dump/dumps functions.
On Thu, Nov 6, 2008 at 01:17, Darthmahon <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Ok I'm using the following cod
Hi,
Ok I'm using the following code to turn my model into JSON:
from django.core import serializers
json = serializers.serialize("json", Event.objects.all()[:5],
fields=('title','date','location'))
Now, this returns JSON like this:
[
{ "pk": 1, "model": "events.event", "fields": {
7 matches
Mail list logo