Q:

Display the descriptive status of options

I define a article_table model data in modles.py, especially set a options attribute for status
class Article(models.Model):
    STATUS = (
        (0,  'normal'),
        (-1, 'deleted'),
    )
    block = models.ForeignKey(Block, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    author = models.CharField(max_length=100)
    content = models.CharField(max_length=1000) # set the widget
    status = models.IntegerField(choices=STATUS)
    date_created = models.DateTimeField(default=datetime.now)
    date_updated = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.title

When I check the responded html, it display status with 0 from database rather than its description 'normal'

The status did not show normal as I intended.
The template of article_list.html
<table class="table table-bordered">
    <tr>
        <th>Status</th>
        <th>Title</th>
        <th>Author</th>
        <th>Latest Updated</th>
    </tr>
    {% for article in articles %}
    <tr>
        <td>{{ article.status }}</td>
        <td>{{ article.title }}</td>
        <td>{{ article.author }}</td>
        <td>{{ article.date_updated }}</td>
    </tr>
    {% endfor %}
</table>

How to solve such a problem?

A:

If you use choices, then you can use get_<fieldname>_display() in the template, like this:
{{ article.get_status_display }}

