title: How to add a calculated field to a Django model
body: <p>I have a simple <code>Employee</code> model that includes <code>firstname</code>,  <code>lastname</code> and <code>middlename</code> fields.</p>
  
  <p>On the admin side and likely elsewhere, I would like to display that as:</p>
  
  <pre><code>lastname, firstname middlename
  </code></pre>
  
  <p>To me the logical place to do this is in the model by creating a calculated field as such:</p>
  
  <pre><code>from django.db import models
  from django.contrib import admin
  
  class Employee(models.Model):
      lastname = models.CharField("Last", max_length=64)
      firstname = models.CharField("First", max_length=64)
      middlename = models.CharField("Middle", max_length=64)
      clocknumber = models.CharField(max_length=16)
      name = ''.join(
          [lastname.value_to_string(),
          ',',
           firstname.value_to_string(),
          ' ',
           middlename.value_to_string()])
  
      class Meta:
          ordering = ['lastname','firstname', 'middlename']
  
  class EmployeeAdmin(admin.ModelAdmin):
      list_display = ('clocknumber','name')
      fieldsets = [("Name", {"fields":(("lastname", "firstname", "middlename"), "clocknumber")}),
          ]
  
  admin.site.register(Employee, EmployeeAdmin)
  </code></pre>
  
  <p>Ultimately what I think I need is to get the value of the name fields as strings.  The error I am getting is <code>value_to_string() takes exactly 2 arguments (1 given)</code>.  Value to string wants <code>self, obj</code>.  I am not sure what <code>obj</code> means.  </p>
  
  <p>There must be an easy way to do this, I am sure I am not the first to want to do this.</p>
  
  <p>Edit:  Below is my code modified to Daniel's answer.  The error I get is:</p>
  
  <blockquote>
  <pre><code>django.core.exceptions.ImproperlyConfigured: 
      EmployeeAdmin.list_display[1], 'name' is not a callable or an 
      attribute of 'EmployeeAdmin' of found in the model 'Employee'.
  </code></pre>
  </blockquote>
  
  <pre><code>from django.db import models
  from django.contrib import admin
  
  class Employee(models.Model):
      lastname = models.CharField("Last", max_length=64)
      firstname = models.CharField("First", max_length=64)
      middlename = models.CharField("Middle", max_length=64)
      clocknumber = models.CharField(max_length=16)
  
      @property
      def name(self):
          return ''.join(
              [self.lastname,' ,', self.firstname, ' ', self.middlename])
  
      class Meta:
          ordering = ['lastname','firstname', 'middlename']
  
  class EmployeeAdmin(admin.ModelAdmin):
      list_display = ('clocknumber','name')
      fieldsets = [("Name", {"fields":(("lastname", "firstname", "middlename"), "clocknumber")}),
  ]
  
  admin.site.register(Employee, EmployeeAdmin)
  </code></pre>