Add redirection and URL counter

parent 1143bf2a
from django.shortcuts import render
from django.shortcuts import render, redirect
from .models import Url
......@@ -11,7 +11,10 @@ def index(request):
return render(request, 'index.html', context)
def redir(request, url_id):
return HttpResponse("You are following the url: {}".format(url_id))
u = Url.objects.get(id=url_id)
u.used += 1
u.save()
return redirect(u.target)
def details(request, url_id):
context = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment