| 1 |
""" |
| 2 |
Adding __str__() to models |
| 3 |
|
| 4 |
Although it's not a strict requirement, each model should have a ``_str__()`` |
| 5 |
method to return a "human-readable" representation of the object. Do this not |
| 6 |
only for your own sanity when dealing with the interactive prompt, but also |
| 7 |
because objects' representations are used throughout Django's |
| 8 |
automatically-generated admin. |
| 9 |
""" |
| 10 |
|
| 11 |
from django.db import models |
| 12 |
|
| 13 |
|
| 14 |
class InternationalArticle(models.Model): |
| 15 |
headline = models.CharField(max_length=100) |
| 16 |
pub_date = models.DateTimeField() |
| 17 |
|
| 18 |
def __str__(self): |
| 19 |
return self.headline |