summaryrefslogtreecommitdiff
path: root/tests/regressiontests/generic_relations_regress/models.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-08-12 12:32:08 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-08-12 14:44:40 +0200
commitd4a0b27838c815af87698920cc4db7d2afd6f05b (patch)
tree6fedc7203389ab1f80f8cc7e913230c51e9b8776 /tests/regressiontests/generic_relations_regress/models.py
parent79d62a71751140315227891bbe175630f9d3edc3 (diff)
[py3] Refactored __unicode__ to __str__.
* Renamed the __unicode__ methods * Applied the python_2_unicode_compatible decorator * Removed the StrAndUnicode mix-in that is superseded by python_2_unicode_compatible * Kept the __unicode__ methods in classes that specifically test it under Python 2
Diffstat (limited to 'tests/regressiontests/generic_relations_regress/models.py')
-rw-r--r--tests/regressiontests/generic_relations_regress/models.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/regressiontests/generic_relations_regress/models.py b/tests/regressiontests/generic_relations_regress/models.py
index 7ec752b02b..dacc9b380b 100644
--- a/tests/regressiontests/generic_relations_regress/models.py
+++ b/tests/regressiontests/generic_relations_regress/models.py
@@ -1,31 +1,36 @@
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.db import models
+from django.utils.encoding import python_2_unicode_compatible
__all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address',
'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2',
'Contact', 'Organization', 'Note')
+@python_2_unicode_compatible
class Link(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
- def __unicode__(self):
+ def __str__(self):
return "Link to %s id=%s" % (self.content_type, self.object_id)
+@python_2_unicode_compatible
class Place(models.Model):
name = models.CharField(max_length=100)
links = generic.GenericRelation(Link)
- def __unicode__(self):
+ def __str__(self):
return "Place: %s" % self.name
+@python_2_unicode_compatible
class Restaurant(Place):
- def __unicode__(self):
+ def __str__(self):
return "Restaurant: %s" % self.name
+@python_2_unicode_compatible
class Address(models.Model):
street = models.CharField(max_length=80)
city = models.CharField(max_length=50)
@@ -35,15 +40,16 @@ class Address(models.Model):
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
- def __unicode__(self):
+ def __str__(self):
return '%s %s, %s %s' % (self.street, self.city, self.state, self.zipcode)
+@python_2_unicode_compatible
class Person(models.Model):
account = models.IntegerField(primary_key=True)
name = models.CharField(max_length=128)
addresses = generic.GenericRelation(Address)
- def __unicode__(self):
+ def __str__(self):
return self.name
class CharLink(models.Model):