title: How to share Python method between two Django classes?
body: <p>I have two classes in my Django models.py file:</p>
  <pre><code>class ProfileManager(models.Manager):
      def create_profile(self, user, member):
          # Set default age to 100 years old when profile is created.
          years_ago100 = datetime.datetime.now() - datetime.timedelta(days=101 * 365)
          age = calculate_age(years_ago100)       # &lt;- Used here
          profile = self.create(user=user, person_dob=years_ago100, person_age=age)
          return
  
  class Profile(models.Model):
      person_dob = models.DateField()
      person_age = models.IntegerField()
  
      objects = ProfileManager()
  
      def save(self, *args, **kwargs):
        # Update to real age when user edits profile for the first time.
        self.person_age = calculate_age(self.person_dob)    # &lt;- Used here too
        super(Profile, self).save(*args, **kwargs)
  </code></pre>
  <p>Each class uses this calculate_age method:</p>
  <pre><code>def calculate_age(born):
      today = datetime.date.today()
      return (today.year - born.year - ((today.month, today.day) &lt; (born.month, born.day)))
  </code></pre>
  <p>How can I make this method accessible to both classes?  One easy way would be to make the method global like this but that seems like a kludgy way to do it:</p>
  <pre><code>def calculate_age(born):
    ...
  
  class ProfileManager(models.Manager):
    ...
  
  class Profile(models.Model):
    ...
  </code></pre>
  <p>Also, this wouldn't work if I wanted to access that method outside of this particular models module.  Is there a standard way to do this when using Django?</p>