title: How to create subscription service using Django
body: <p>I am working on a Django application. I need to include subscription service in the application. I am using the fields <code>is_subscribed</code>, <code>subscription_start</code> and <code>subscription_end</code> in the <code>user profile</code> models. I am using Razorpay for the payment integration. After successful payment I am updating the subscription status as follows:</p>
  <pre><code>UserProfile.objects.filter(user=request.user).update(is_subscribed=True,subscription_start=datetime.datetime.now(),subscription_end=datetime.datetime.now()+datetime.timedelta(days))
  </code></pre>
  <p>How to update the <code>UserProfile</code> automatically as soon the <code>subscription_end</code> is less than the current time. I want the model to be updated as <code>is_subscribed</code> as False as soon as the time is over. As of now, whenever a user visits any url, I am checking whether the user's subscription is valid. If not , then I am updating the model in this way</p>
  <pre><code>user = UserProfile.objects.filter(user=request.user).values()
  
  
   use1 = UserProfile.objects.filter(user=request.user,subscription_end__gte=datetime.datetime.now()).values()
   if not use1[0]['is_admin']:
       UserProfile.objects.filter(user=request.user).update(is_subscribed=False,joined=[])
  </code></pre>
  <p>. what is the correct way to update as soon as the subscription ends.</p>