13 lines
367 B
Python
13 lines
367 B
Python
from django.shortcuts import get_object_or_404
|
|
from django.views.generic.base import RedirectView
|
|
|
|
from .models import ShortURL
|
|
|
|
|
|
class ShorturlsRedirectView(RedirectView):
|
|
def get_redirect_url(self, *args, **kwargs):
|
|
url = get_object_or_404(ShortURL, short_url=kwargs["shorturl"])
|
|
url.followed += 1
|
|
url.save()
|
|
return url.long_url
|