Created
January 13, 2011 20:33
-
-
Save 0x46616c6b/778539 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if request.method == 'GET': | |
# new callback functions | |
if 'format' in request.GET: | |
if request.GET['format'] == 'json': | |
json_serializer = serializers.get_serializer("json")() | |
if 'function' in request.GET: | |
if request.GET['function'] == 'get_all_entries': | |
allEntries = Entry.objects.all().order_by('-published') | |
return HttpResponse(json_serializer.serialize(allEntries, ensure_ascii=False)) | |
elif request.GET['function'] == 'get_latest_entry': | |
latestEntry = Entry.objects.all().order_by('-published')[:1] | |
return HttpResponse(json_serializer.serialize(latestEntry, ensure_ascii=False)) | |
elif request.GET['function'] == 'get_pin': | |
pin = Config.objects.filter(key='pin') | |
return HttpResponse(json_serializer.serialize(pin, ensure_ascii=False)) | |
else: | |
notDefinedMessage = "This method is not defined!" | |
return HttpResponse(notDefinedMessage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment