mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Updated example models to use __str__
in relations docs. (#6433)
This commit is contained in:
parent
63e352586b
commit
7310411533
|
@ -46,12 +46,12 @@ In order to explain the various types of relational fields, we'll use a couple o
|
||||||
unique_together = ('album', 'order')
|
unique_together = ('album', 'order')
|
||||||
ordering = ['order']
|
ordering = ['order']
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return '%d: %s' % (self.order, self.title)
|
return '%d: %s' % (self.order, self.title)
|
||||||
|
|
||||||
## StringRelatedField
|
## StringRelatedField
|
||||||
|
|
||||||
`StringRelatedField` may be used to represent the target of the relationship using its `__unicode__` method.
|
`StringRelatedField` may be used to represent the target of the relationship using its `__str__` method.
|
||||||
|
|
||||||
For example, the following serializer.
|
For example, the following serializer.
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ For example, given the following model for a tag, which has a generic relationsh
|
||||||
object_id = models.PositiveIntegerField()
|
object_id = models.PositiveIntegerField()
|
||||||
tagged_object = GenericForeignKey('content_type', 'object_id')
|
tagged_object = GenericForeignKey('content_type', 'object_id')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.tag_name
|
return self.tag_name
|
||||||
|
|
||||||
And the following two models, which may have associated tags:
|
And the following two models, which may have associated tags:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user