title: Search choice field by the name in django - python
body: <p>I have the below choice field in models. </p>
  
  <pre><code>STATUS_REVIEW_RISK_ESTIMATE_CHOICES = (
      (0, "High"),
      (1, "Medium"),
      (2, "Low"),
  )
  
      class SiverifyProblemStatement(models.Model):
      risk_estimate = models.PositiveIntegerField(null=True, blank=True, choices=STATUS_REVIEW_RISK_ESTIMATE_CHOICES)
  </code></pre>
  
  <p>When I try to render the values from db(eventually stored as integers(0,1,2). I'm using the following code which helps me to display the name of the choices(High, Medium and low). </p>
  
  <p>Render code:</p>
  
  <pre><code>def render_risk_estimate(self, **kwargs):
          try:
             stmt = kwargs['row_obj'].revision_problem_statements.latest('id')
          except ObjectDoesNotExist:
              return None
          return (stmt and stmt.get_risk_estimate_display() or None)
  </code></pre>
  
  <p>But when I try to establish the same for searching the field with choice names, I get an error stating get_risk_estimate_display() is not an attribute. However, when I tried this, I'm able to search the field with integer choices. </p>
  
  <p>Tried code:</p>
  
  <pre><code>class ReviewWorklistDTView(GroupDTListView):
  columns = [{'data': 'risk_estimate','_get': 'id', 'title':'Risk Estimation', '_search':'revision_problem_statements__risk_estimate', '_type': 'char'},]
  </code></pre>
  
  <p>This helps me in searching with the integer choices not with respect to the values in it. I did looked up at the following questions, but nothing seems to be helping my part. </p>
  
  <pre><code>http://stackoverflow.com/questions/22043054/search-field-by-field-choice
  http://stackoverflow.com/questions/12626171/django-admin-choice-field
  https://github.com/sivaa/django-custom-search-filter/blob/master/app/admin.py
  </code></pre>