url_shortener/views.py
def retrieve(self, request, *args, **kwargs):
        """
        Override the model instance retrieval method.
        Instead of building a standard response with the model instance,
        it redirects the short URL to the real, longer URL ('url' model field)
        it's linked to.
        Just before the redirection is performed the 'usage_count' model field
        is incremented.
        """
        instance = self.get_object()
        instance.usage_count += 1
        instance.save()
        return HttpResponsePermanentRedirect(instance.url)

        Override the model instance retrieval method.
        Instead of building a standard response with the model instance,
        it redirects the short URL to the real, longer URL ('url' model field)
        it's linked to.
        Just before the redirection is performed the 'usage_count' model field
        is incremented.
        
Override the model instance retrieval method.
Instead of building a standard response with the model instance,
it redirects the short URL to the real, longer URL ('url' model field)
it's linked to.
Just before the redirection is performed the 'usage_count' model field
is incremented.
Override the model instance retrieval method . Instead of building a standard response with the model instance it redirects the short URL to the real longer URL ( ' url ' model field ) it ' s linked to . Just before the redirection is performed the ' usage_count ' model field is incremented .
def retrieve(self, request, *args, **kwargs):
        instance = self.get_object()
        instance.usage_count += 1
        instance.save()
        return HttpResponsePermanentRedirect(instance.url)
def retrieve ( self , request , * args , ** kwargs ) : instance = self . get_object ( ) instance . usage_count += 1 instance . save ( ) return HttpResponsePermanentRedirect ( instance . url )
Override the model instance retrieval method.
Override the model instance retrieval method .
"""
        Override the model instance retrieval method.
        Instead of building a standard response with the model instance,
        it redirects the short URL to the real, longer URL ('url' model field)
        it's linked to.
        Just before the redirection is performed the 'usage_count' model field
        is incremented.
        """
self
request