title: Compare object field in Django template
body: <p>I have a model</p>
  
  <pre><code>class Applicant(models.Model):
      job = models.ForeignKey(Job)
      location = models.ForeignKey(Location)
      type = models.ForeignKey(Type)
  </code></pre>
  
  <p>Where <code>type</code> refers to another table:</p>
  
  <pre><code>class Type(models.Model):
      """ Model for Applicant Type
  
      Attributes:
          type: string
      """
  
      type = models.CharField(max_length=45)
  
      def __str__(self):
          """ Override for __str__ method
          """
          return self.type
  
      class Meta:
          managed = False
          db_table = 'jobs_type'
  </code></pre>
  
  <p>I can access an object's type in the template by simply writing the following:</p>
  
  <pre><code>&lt;h3&gt;{{applicant.type}}&lt;/h3&gt;
  </code></pre>
  
  <p>Where <code>applicant</code> is the Applicant object. However, when I try and compare the type to a String, the comparison fails:</p>
  
  <pre><code>{% if applicant.type == "Driver" %}
      &lt;h3&gt;{{applicant.type}}&lt;/h3&gt;
  {% else %}
      &lt;h3&gt;{{applicant.type}} does not equal "Driver"&lt;/h3&gt;
  {% endif %}
  </code></pre>
  
  <p>Printing:</p>
  
  <pre><code>Driver does not equal "Driver"
  </code></pre>
  
  <p>Is there a better way to compare object fields in a Django template?</p>
  
  <p>The "Type" field in the jobs_type table of the database is a varChar.</p>