title: Django UpdateView allow only if object fields meet certain conditions
body: <p>I want that an <code>Invoice</code> may only be changed if it falls between certain dates; these two dates are stored in the DB and indicate the currently open month (to prevent users from changing old invoices).</p>
  
  <p>Where would be the best place to enforce this restriction in my <code>InvoiceUpdateView</code>?</p>
  
  <p>A simple solution: add form validation (method <code>InvoiceForm.clean_date()</code>). That works, but ideally, I want the <code>InvoiceUpdateView</code> to not even show the form if the <code>Invoice</code> date is outside of the established range, it should just redirect back to the <code>InvoiceDetailView</code>.</p>
  
  <p>The following code works, but it calls <code>.get_object()</code> twice: I have to call it once to get the objects date, and later this method is called again in the parents <code>.get()</code> or <code>.post()</code>.</p>
  
  <pre><code>class Invoice(models.Model):
      date = models.DateField()
      ... more fields ...
  
  class InvoiceUpdateView(PermissionRequiredMixin, UpdateView):
      permission_required = ...
      template_name = ...
      model = Invoice
      fields = ...
  
      def can_be_modified(self):
          # fetch from DB
          start_date = ...
          end_date = ...
  
          if start_date &lt;= self.object.date &lt;= end_date:
              return True
          return False
  
      def get(self, request, *args, **kwargs):
          self.object = self.get_object()
          if not self.can_be_modified():
              return redirect('invoice-detail')
  
          return super().get(request, *args, **kwargs)
  
      def post(self, request, *args, **kwargs):
          self.object = self.get_object()
          if not self.can_be_modified():
              return redirect('invoice-detail')
  
          return super().post(request, *args, **kwargs)
  </code></pre>
  
  <p>Does anyone have a better suggestion/approach? Or is there a good argument to just stick with simple form validation?</p>
  
  <p>In case it matters: <code>python 3.5</code> with <code>django 1.11</code></p>