title: Define age in django template using actual datatime and birthday with datafield
body: <p>i'm begginer at django and trying to display age for every user in my base of users. </p>
  
  <p>Here's my code:</p>
  
  <p>models.py:</p>
  
  <pre><code>class Cv(models.Model):
      author = models.ForeignKey('auth.User')
      name = models.CharField(max_length=25, null = True)
      surname = models.CharField(max_length=25, null = True)
      address = models.CharField(max_length=100, blank=True)
      telephone = models.IntegerField()
      birth_date = models.DateField(blank=True, null=True)
      email = models.EmailField(max_length=50, null=True)
      skills = models.TextField(null=True)
      specialization = models.CharField(max_length=30, blank=True, null=True)
      interests = models.TextField(blank=True, null=True)
      summary = models.TextField(blank=True, null=True)
      thumbnail = models.FileField(upload_to=get_upload_file_name, blank=True)
  
  
  
  
      def zapisz(self):
          self.save()
  
      def __str__(self):
          return self.surname
  </code></pre>
  
  <p>template.html:</p>
  
  <pre><code>{% block base %}
  &lt;div class="vvv"&gt;
      &lt;h2&gt;Base of users&lt;/h2&gt;&lt;hr&gt;
      &lt;table id="example" class="display" cellspacing="0" width="100%"&gt;
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;th&gt;Nr.&lt;/th&gt;
              &lt;th&gt;Full Name&lt;/th&gt;
              &lt;th&gt;Specialization&lt;/th&gt;     
              &lt;th&gt;Age&lt;/th&gt;
              &lt;th&gt;E-mail&lt;/th&gt;
            &lt;/tr&gt;
           &lt;/thead&gt;
           &lt;tbody&gt;
            {% for cv in cvs %}
                &lt;tr&gt;
                  &lt;td&gt;{{forloop.counter}}.&lt;/td&gt;
                  &lt;td&gt;&lt;a href="{% url "proj.views.cv_detail" pk=cv.pk %}"&gt;{{cv.name}} {{cv.surname}}&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;{{cv.specialization}}&lt;/td&gt;      
                  &lt;td&gt;{{ cv.age }} &lt;/td&gt;
                  &lt;td&gt;{{cv.email}}&lt;/td&gt;
                &lt;/tr&gt;
            {% endfor %}
            &lt;/tbody&gt;
      &lt;/table&gt;&lt;br&gt;
  
  
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>@login_required
  def base_cv(request):
  
      cvs = Cv.objects.filter()
  
      for cv in cvs:
  
          def calculate_age(self):
              import datetime
              return int((datetime.datetime.now() - cv.birth_date).days / 365.25  )
  
          age = property(calculate_age)
  
      con = {
  
      'cvs': cvs,
      'age': age,
      }
  
      return render(request, 'base_cv.html', con)
  </code></pre>
  
  <p>And don't know why the fields after rendering and displaying, are empty.</p>
  
  <p>Thanks for any help!</p>