title: When exactly is Django2.2 View __init__() called? When are views' definitions called?
body: <p><strong>My objective:
  To get the func called only once, when the application (not whole django project, but a specific app) is started.</strong></p>
  
  <p>the below is taken from the documentation of the generic class View's <strong>init</strong> method (django/views/generic/base.py):</p>
  
  <blockquote>
    <p>Constructor. Called in the URLconf; can contain helpful extra
            keyword arguments, and other things.</p>
  </blockquote>
  
  <p>If my two experimental views are subclassing View and some other non-view classes and the code looks like more or less like below. NB, the function func() has some important side-effects and I am interested WHEN and HOW OFTEN they are called. I only know that in case of MyView, the func will be called each time the class Parent IS DEFINED, in case of MyView2, each time Parent2 or MyView2 is CALLED. But I fail to grasp when does this (respectively) happen - i.g. on each import, just once, on running the application, each time the endpoint is hit. Could someone explain me a bit those two cases? :)
  this:</p>
  
  <blockquote>
    <p>Because Django’s URL resolver expects to send the request and associated arguments to a callable function, not a class, class-based views have an as_view() class method which returns a function that can be called when a request arrives for a URL matching the associated pattern. The function creates an instance of the class, calls setup() to initialize its attributes, and then calls its dispatch() method.</p>
  </blockquote>
  
  <p>suggests that in case of MyView2 the func will be called each time the respective endpoint is hit. Is that so? And <strong>what about the MyView? In that case the func gets called whenever the Parent class is defined. Parent class is not a view (although it is defined in the views.py), there is no endpoint connected to it. So it gets probably executed when the views.py file is imported. I should think it would get called only once, when application is started - but I get two func calls instead...</strong></p>
  
  <pre><code>class Parent:
      var = func()
  
  
  class MyView(View, Parent):
      #... some usual stuff here
  
  class Parent2:
      def __init__(self):
          self.var = func()
  
  
  class MyView2(View, Parent2):
      #... some usual staff here
  </code></pre>