you are already basically there
id = request.GET.get('id')
if id:
ids = id.split(',')
slideshows = slideshow.objects.filter(id__in=ids)
then returns that as json however you like
On Mar 8, 11:41 pm, Nick <[email protected]> wrote:
> I am working on an api that outputs a list of JSON based on certain
> criteria. Currently if someone
> entershttp://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,
> sohttp://example.mysite/slideshows/api?id=1,2,5,9,10will 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.