Example #1
0
 def get(self, _):
     urlid = utoi(self.short)
     try:
         shorturl = URL.objects.get(id=urlid)
         shorturl.clicks += 1
         shorturl.save()
     except (URL.DoesNotExist, OverflowError):
         # OverflowError is odd, see
         raise Http404("%s not in database" % self.short)
     return HttpResponseRedirect(shorturl.url)
Example #2
0
 def dispatch(self, request, *args, **kwargs):
     self.pk = utoi(kwargs.pop('short'))
     return super(Results, self).dispatch(request, *args, **kwargs)