Skip to content

Instantly share code, notes, and snippets.

@Ell
Created April 13, 2011 21:24
Show Gist options
  • Save Ell/918453 to your computer and use it in GitHub Desktop.
Save Ell/918453 to your computer and use it in GitHub Desktop.
def cat_tag(request):
if request.is_ajax():
if request.method == 'GET':
id = request.GET['id']
tagging = Images.objects.get(id=id)
tags = Tag.objects.usage_for_model(tagging, counts=True)
usageNum = [{"tag": tagfreq.name, "count": tagfreq.count} for tagfreq in tags]
dump = simplejson.dumps(usageNum)
message = dump
elif request.method == 'POST':
id = request.POST['id']
tags = request.POST['tags']
tagging = Images.objects.get(id=id)
tagarray = parse_tag_input(tags)
for dicks in tagarray:
Tag.objects.add_tag(tagging, dicks)
message = "Ok!"
else:
message = "not validated."
return HttpResponse(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment