mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #21951 -- Updated docs to use __str__ for Python 3
Thanks Tim Graham for the report and recommendations
This commit is contained in:
parent
c3434fed5b
commit
8aa1efff6d
20 changed files with 71 additions and 72 deletions
|
@ -16,8 +16,7 @@ objects, and a ``Publication`` has multiple ``Article`` objects:
|
|||
class Publication(models.Model):
|
||||
title = models.CharField(max_length=30)
|
||||
|
||||
# On Python 3: def __str__(self):
|
||||
def __unicode__(self):
|
||||
def __str__(self): # __unicode__ on Python 2
|
||||
return self.title
|
||||
|
||||
class Meta:
|
||||
|
@ -27,8 +26,7 @@ objects, and a ``Publication`` has multiple ``Article`` objects:
|
|||
headline = models.CharField(max_length=100)
|
||||
publications = models.ManyToManyField(Publication)
|
||||
|
||||
# On Python 3: def __str__(self):
|
||||
def __unicode__(self):
|
||||
def __str__(self): # __unicode__ on Python 2
|
||||
return self.headline
|
||||
|
||||
class Meta:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue