[Django]-Handling a license-like system with Django

4👍

You can make use of middlewares

  1. Create a middleware.py and below code

    class LicenceMiddleware:
    
     def __init__(self, get_response):
            self.get_response = get_response
            # One-time configuration and initialization.
    
    
    def __call__(self, request):
        # Code to be executed for each request before
        # the view (and later middleware) are called.
    
        response = self.get_response(request)
    
    
        if check_date:
            return response
        else:
            return render(request, 'licence_expired.html')
    
  2. Add your middleware to settings.py middleware section

Now for each request/response it checks the licencemiddleware and returns response.

You can create one more field in model to keep track the date.

👤DPS

Leave a comment