I am working on an api that outputs a list of JSON based on certain
criteria.  Currently if someone enters http://example.mysite/slideshows/api?id=1
it returns a JSON serialized output of the slideshow with that ID.

What I would like to do is allow for multiple ids, so
http://example.mysite/slideshows/api?id=1,2,5,9,10 will pull in JSON
values for each of those slideshows.

I'd like to keep from using a third party API solution, I have checked
them out and I like the customization with the hand built process

I am doing everything through a get process in a view, here it is:


def slideshowAPI2(request):
    error = False
    if 'id' in request.GET and request.GET['id']:
        id = request.GET['id']
        object = slideshow.objects.get(pk=id)
        return render_to_response('slideshow.json',
            {'object': object, 'id':id})
    if 'year' in request.GET and request.GET['year']:
        year = request.GET['year']
        object = serializers.serialize("json",
slideshow.objects.filter(publishdate__year=year))
        html = "%s" % object
        return HttpResponse(html)
    else:
        error = True
        return render_to_response('slideshow.json', {'error': True})

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to