Ticket #2077: models.py.diff
File models.py.diff, 881 bytes (added by , 18 years ago) |
---|
-
tests/modeltests/repr/models.py
1 1 """ 2 2. Adding __ repr__() to models2 2. Adding __str__() to models 3 3 4 Although it's not a strict requirement, each model should have a ``__ repr__()``4 Although it's not a strict requirement, each model should have a ``__str__()`` 5 5 method to return a "human-readable" representation of the object. Do this not 6 6 only for your own sanity when dealing with the interactive prompt, but also 7 7 because objects' representations are used throughout Django's … … 14 14 headline = models.CharField(maxlength=100) 15 15 pub_date = models.DateTimeField() 16 16 17 def __ repr__(self):17 def __str__(self): 18 18 return self.headline 19 19 20 20 API_TESTS = """