diff --git a/tests/annotations/models.py b/tests/annotations/models.py index cd3d6ddb872..c8fbe177929 100644 --- a/tests/annotations/models.py +++ b/tests/annotations/models.py @@ -6,17 +6,11 @@ class Author(models.Model): age = models.IntegerField() friends = models.ManyToManyField('self', blank=True) - def __str__(self): - return self.name - class Publisher(models.Model): name = models.CharField(max_length=255) num_awards = models.IntegerField() - def __str__(self): - return self.name - class Book(models.Model): isbn = models.CharField(max_length=9) @@ -29,9 +23,6 @@ class Book(models.Model): publisher = models.ForeignKey(Publisher, models.CASCADE) pubdate = models.DateField() - def __str__(self): - return self.name - class Store(models.Model): name = models.CharField(max_length=255) @@ -40,16 +31,10 @@ class Store(models.Model): friday_night_closing = models.TimeField() area = models.IntegerField(null=True, db_column='surface') - def __str__(self): - return self.name - class DepartmentStore(Store): chain = models.CharField(max_length=255) - def __str__(self): - return '%s - %s ' % (self.chain, self.name) - class Employee(models.Model): # The order of these fields matter, do not change. Certain backends @@ -62,9 +47,6 @@ class Employee(models.Model): age = models.IntegerField() salary = models.DecimalField(max_digits=8, decimal_places=2) - def __str__(self): - return '%s %s' % (self.first_name, self.last_name) - class Company(models.Model): name = models.CharField(max_length=200) @@ -81,6 +63,3 @@ class Company(models.Model): class Ticket(models.Model): active_at = models.DateTimeField() duration = models.DurationField() - - def __str__(self): - return '{} - {}'.format(self.active_at, self.duration) diff --git a/tests/custom_lookups/models.py b/tests/custom_lookups/models.py index 071858cd3d1..b1d809a5c91 100644 --- a/tests/custom_lookups/models.py +++ b/tests/custom_lookups/models.py @@ -17,6 +17,3 @@ class Article(models.Model): class MySQLUnixTimestamp(models.Model): timestamp = models.PositiveIntegerField() - - def __str__(self): - return self.name diff --git a/tests/datatypes/models.py b/tests/datatypes/models.py index 6e31a3a4532..ce78470f61c 100644 --- a/tests/datatypes/models.py +++ b/tests/datatypes/models.py @@ -19,9 +19,6 @@ class Donut(models.Model): class Meta: ordering = ('consumed_at',) - def __str__(self): - return self.name - class RumBaba(models.Model): baked_date = models.DateField(auto_now_add=True) diff --git a/tests/dates/models.py b/tests/dates/models.py index 7f710ce1ea7..2ed092587fe 100644 --- a/tests/dates/models.py +++ b/tests/dates/models.py @@ -9,9 +9,6 @@ class Article(models.Model): categories = models.ManyToManyField("Category", related_name="articles") - def __str__(self): - return self.title - class Comment(models.Model): article = models.ForeignKey(Article, models.CASCADE, related_name="comments") @@ -19,9 +16,6 @@ class Comment(models.Model): pub_date = models.DateField() approval_date = models.DateField(null=True) - def __str__(self): - return 'Comment to %s (%s)' % (self.article.title, self.pub_date) - class Category(models.Model): name = models.CharField(max_length=255) diff --git a/tests/from_db_value/models.py b/tests/from_db_value/models.py index 5c5e5e1dbf3..58e8ec3a272 100644 --- a/tests/from_db_value/models.py +++ b/tests/from_db_value/models.py @@ -6,10 +6,6 @@ from django.db import models class Cash(decimal.Decimal): currency = 'USD' - def __str__(self): - s = super().__str__(self) - return '%s %s' % (s, self.currency) - class CashField(models.DecimalField): def __init__(self, **kwargs): @@ -25,6 +21,3 @@ class CashField(models.DecimalField): class CashModel(models.Model): cash = CashField() - - def __str__(self): - return str(self.cash) diff --git a/tests/get_object_or_404/models.py b/tests/get_object_or_404/models.py index 04f22dd0492..24c6aa975c8 100644 --- a/tests/get_object_or_404/models.py +++ b/tests/get_object_or_404/models.py @@ -16,9 +16,6 @@ from django.db import models class Author(models.Model): name = models.CharField(max_length=50) - def __str__(self): - return self.name - class ArticleManager(models.Manager): def get_queryset(self): @@ -36,6 +33,3 @@ class Article(models.Model): objects = models.Manager() by_a_sir = ArticleManager() attribute_error_objects = AttributeErrorManager() - - def __str__(self): - return self.title diff --git a/tests/introspection/models.py b/tests/introspection/models.py index c3f6338176a..72881cf43c0 100644 --- a/tests/introspection/models.py +++ b/tests/introspection/models.py @@ -5,9 +5,6 @@ class City(models.Model): id = models.BigAutoField(primary_key=True) name = models.CharField(max_length=50) - def __str__(self): - return self.name - class Country(models.Model): id = models.SmallAutoField(primary_key=True) @@ -18,9 +15,6 @@ class District(models.Model): city = models.ForeignKey(City, models.CASCADE, primary_key=True) name = models.CharField(max_length=50) - def __str__(self): - return self.name - class Reporter(models.Model): first_name = models.CharField(max_length=30) @@ -34,9 +28,6 @@ class Reporter(models.Model): class Meta: unique_together = ('first_name', 'last_name') - def __str__(self): - return "%s %s" % (self.first_name, self.last_name) - class Article(models.Model): headline = models.CharField(max_length=100) @@ -53,9 +44,6 @@ class Article(models.Model): ['headline', 'response_to', 'pub_date', 'reporter'], ] - def __str__(self): - return self.headline - class ArticleReporter(models.Model): article = models.ForeignKey(Article, models.CASCADE) diff --git a/tests/null_fk/models.py b/tests/null_fk/models.py index 5ebce93a654..01f69c1807b 100644 --- a/tests/null_fk/models.py +++ b/tests/null_fk/models.py @@ -34,9 +34,6 @@ class Comment(models.Model): class Meta: ordering = ('comment_text',) - def __str__(self): - return self.comment_text - # Ticket 15823 diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py index e803c989e07..24605954b2f 100644 --- a/tests/postgres_tests/models.py +++ b/tests/postgres_tests/models.py @@ -89,9 +89,6 @@ class CharFieldModel(models.Model): class TextFieldModel(models.Model): field = models.TextField() - def __str__(self): - return self.field - class SmallAutoFieldModel(models.Model): id = models.SmallAutoField(primary_key=True) @@ -107,16 +104,10 @@ class Scene(models.Model): scene = models.CharField(max_length=255) setting = models.CharField(max_length=255) - def __str__(self): - return self.scene - class Character(models.Model): name = models.CharField(max_length=255) - def __str__(self): - return self.name - class CITestModel(PostgreSQLModel): name = CICharField(primary_key=True, max_length=255) @@ -124,9 +115,6 @@ class CITestModel(PostgreSQLModel): description = CITextField() array_field = ArrayField(CITextField(), null=True) - def __str__(self): - return self.name - class Line(PostgreSQLModel): scene = models.ForeignKey('Scene', models.CASCADE) @@ -135,9 +123,6 @@ class Line(PostgreSQLModel): dialogue_search_vector = SearchVectorField(blank=True, null=True) dialogue_config = models.CharField(max_length=100, blank=True, null=True) - def __str__(self): - return self.dialogue or '' - class LineSavedSearch(PostgreSQLModel): line = models.ForeignKey('Line', models.CASCADE) diff --git a/tests/signals/models.py b/tests/signals/models.py index 960df390de0..ca30cdc51f5 100644 --- a/tests/signals/models.py +++ b/tests/signals/models.py @@ -16,9 +16,6 @@ class Car(models.Model): make = models.CharField(max_length=20) model = models.CharField(max_length=20) - def __str__(self): - return "%s %s" % (self.make, self.model) - class Author(models.Model): name = models.CharField(max_length=20) diff --git a/tests/sites_framework/models.py b/tests/sites_framework/models.py index fb6a9d4e79c..fcedbe295f8 100644 --- a/tests/sites_framework/models.py +++ b/tests/sites_framework/models.py @@ -12,9 +12,6 @@ class AbstractArticle(models.Model): class Meta: abstract = True - def __str__(self): - return self.title - class SyndicatedArticle(AbstractArticle): sites = models.ManyToManyField(Site) diff --git a/tests/string_lookup/models.py b/tests/string_lookup/models.py index 5351ee5fe93..48001b42d7a 100644 --- a/tests/string_lookup/models.py +++ b/tests/string_lookup/models.py @@ -5,9 +5,6 @@ class Foo(models.Model): name = models.CharField(max_length=50) friend = models.CharField(max_length=50, blank=True) - def __str__(self): - return "Foo %s" % self.name - class Bar(models.Model): name = models.CharField(max_length=50) @@ -15,36 +12,21 @@ class Bar(models.Model): fwd = models.ForeignKey("Whiz", models.CASCADE) back = models.ForeignKey("Foo", models.CASCADE) - def __str__(self): - return "Bar %s" % self.place.name - class Whiz(models.Model): name = models.CharField(max_length=50) - def __str__(self): - return "Whiz %s" % self.name - class Child(models.Model): parent = models.OneToOneField('Base', models.CASCADE) name = models.CharField(max_length=50) - def __str__(self): - return "Child %s" % self.name - class Base(models.Model): name = models.CharField(max_length=50) - def __str__(self): - return "Base %s" % self.name - class Article(models.Model): name = models.CharField(max_length=50) text = models.TextField() submitted_from = models.GenericIPAddressField(blank=True, null=True) - - def __str__(self): - return "Article %s" % self.name diff --git a/tests/syndication_tests/models.py b/tests/syndication_tests/models.py index f6c499ccca2..0ca47c24ebc 100644 --- a/tests/syndication_tests/models.py +++ b/tests/syndication_tests/models.py @@ -19,6 +19,3 @@ class Entry(models.Model): class Article(models.Model): title = models.CharField(max_length=200) entry = models.ForeignKey(Entry, models.CASCADE) - - def __str__(self): - return self.title diff --git a/tests/test_utils/models.py b/tests/test_utils/models.py index f48c90dd089..c40801f81b3 100644 --- a/tests/test_utils/models.py +++ b/tests/test_utils/models.py @@ -4,17 +4,11 @@ from django.db import models class Car(models.Model): name = models.CharField(max_length=100) - def __str__(self): - return self.name - class Person(models.Model): name = models.CharField(max_length=100) cars = models.ManyToManyField(Car, through='PossessedCar') - def __str__(self): - return self.name - class PossessedCar(models.Model): car = models.ForeignKey(Car, models.CASCADE) diff --git a/tests/transaction_hooks/models.py b/tests/transaction_hooks/models.py index d3abbfef91d..000fd71ca20 100644 --- a/tests/transaction_hooks/models.py +++ b/tests/transaction_hooks/models.py @@ -3,6 +3,3 @@ from django.db import models class Thing(models.Model): num = models.IntegerField() - - def __str__(self): - return "Thing %d" % self.num diff --git a/tests/unmanaged_models/models.py b/tests/unmanaged_models/models.py index c8da49aa079..a3aefbe8826 100644 --- a/tests/unmanaged_models/models.py +++ b/tests/unmanaged_models/models.py @@ -15,9 +15,6 @@ class A01(models.Model): class Meta: db_table = 'a01' - def __str__(self): - return self.f_a - class B01(models.Model): fk_a = models.ForeignKey(A01, models.CASCADE) @@ -29,9 +26,6 @@ class B01(models.Model): # 'managed' is True by default. This tests we can set it explicitly. managed = True - def __str__(self): - return self.f_a - class C01(models.Model): mm_a = models.ManyToManyField(A01, db_table='d01') @@ -41,8 +35,6 @@ class C01(models.Model): class Meta: db_table = 'c01' - def __str__(self): - return self.f_a # All of these models use the same tables as the previous set (they are shadows # of possibly a subset of the columns). There should be no creation errors, @@ -56,9 +48,6 @@ class A02(models.Model): db_table = 'a01' managed = False - def __str__(self): - return self.f_a - class B02(models.Model): class Meta: @@ -69,9 +58,6 @@ class B02(models.Model): f_a = models.CharField(max_length=10, db_index=True) f_b = models.IntegerField() - def __str__(self): - return self.f_a - # To re-use the many-to-many intermediate table, we need to manually set up # things up. @@ -84,9 +70,6 @@ class C02(models.Model): db_table = 'c01' managed = False - def __str__(self): - return self.f_a - class Intermediate(models.Model): a02 = models.ForeignKey(A02, models.CASCADE, db_column="a01_id") diff --git a/tests/update/models.py b/tests/update/models.py index b56dd2258ec..78619876048 100644 --- a/tests/update/models.py +++ b/tests/update/models.py @@ -11,17 +11,11 @@ class DataPoint(models.Model): value = models.CharField(max_length=20) another_value = models.CharField(max_length=20, blank=True) - def __str__(self): - return self.name - class RelatedPoint(models.Model): name = models.CharField(max_length=20) data = models.ForeignKey(DataPoint, models.CASCADE) - def __str__(self): - return self.name - class A(models.Model): x = models.IntegerField(default=10) diff --git a/tests/update_only_fields/models.py b/tests/update_only_fields/models.py index 7308c75ea37..b7100398cd9 100644 --- a/tests/update_only_fields/models.py +++ b/tests/update_only_fields/models.py @@ -15,9 +15,6 @@ class Person(models.Model): gender = models.CharField(max_length=1, choices=GENDER_CHOICES) pid = models.IntegerField(null=True, default=None) - def __str__(self): - return self.name - class Employee(Person): employee_num = models.IntegerField(default=0) @@ -29,9 +26,6 @@ class Profile(models.Model): name = models.CharField(max_length=200) salary = models.FloatField(default=1000.0) - def __str__(self): - return self.name - class ProxyEmployee(Employee): class Meta: diff --git a/tests/validation/models.py b/tests/validation/models.py index e8e18cfbcec..47fb895ec5d 100644 --- a/tests/validation/models.py +++ b/tests/validation/models.py @@ -94,9 +94,6 @@ class Post(models.Model): subtitle = models.CharField(max_length=50, unique_for_month='posted', blank=True) posted = models.DateField() - def __str__(self): - return self.name - class FlexibleDatePost(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) diff --git a/tests/view_tests/models.py b/tests/view_tests/models.py index 04e31c43da0..a9c0b358b48 100644 --- a/tests/view_tests/models.py +++ b/tests/view_tests/models.py @@ -8,9 +8,6 @@ from django.db import models class Author(models.Model): name = models.CharField(max_length=100) - def __str__(self): - return self.name - def get_absolute_url(self): return '/authors/%s/' % self.id @@ -27,9 +24,6 @@ class BaseArticle(models.Model): class Meta: abstract = True - def __str__(self): - return self.title - class Article(BaseArticle): date_created = models.DateTimeField()