1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #30947 -- Changed tuples to lists in model Meta options in django.contrib modules.

The Django "Model Meta options" docs provide examples and generally
point the reader to use lists for the unique_together and ordering
options. Follow our own advice for contrib models.

More generally, lists should be used for homogeneous sequences of
arbitrary lengths of which both unique_together and ordering are.
This commit is contained in:
Jon Dufresne 2019-04-24 03:44:13 -07:00 committed by Mariusz Felisiak
parent e5cacb1f47
commit b9fe7f9294
12 changed files with 18 additions and 14 deletions

View File

@ -34,7 +34,7 @@ class Migration(migrations.Migration):
)),
],
options={
'ordering': ('-action_time',),
'ordering': ['-action_time'],
'db_table': 'django_admin_log',
'verbose_name': 'log entry',
'verbose_name_plural': 'log entries',

View File

@ -66,7 +66,7 @@ class LogEntry(models.Model):
verbose_name = _('log entry')
verbose_name_plural = _('log entries')
db_table = 'django_admin_log'
ordering = ('-action_time',)
ordering = ['-action_time']
def __repr__(self):
return str(self.action_time)

View File

@ -25,7 +25,7 @@ class Migration(migrations.Migration):
('codename', models.CharField(max_length=100, verbose_name='codename')),
],
options={
'ordering': ('content_type__app_label', 'content_type__model', 'codename'),
'ordering': ['content_type__app_label', 'content_type__model', 'codename'],
'unique_together': {('content_type', 'codename')},
'verbose_name': 'permission',
'verbose_name_plural': 'permissions',

View File

@ -66,9 +66,8 @@ class Permission(models.Model):
class Meta:
verbose_name = _('permission')
verbose_name_plural = _('permissions')
unique_together = (('content_type', 'codename'),)
ordering = ('content_type__app_label', 'content_type__model',
'codename')
unique_together = [['content_type', 'codename']]
ordering = ['content_type__app_label', 'content_type__model', 'codename']
def __str__(self):
return '%s | %s' % (self.content_type, self.name)

View File

@ -139,7 +139,7 @@ class ContentType(models.Model):
verbose_name = _('content type')
verbose_name_plural = _('content types')
db_table = 'django_content_type'
unique_together = (('app_label', 'model'),)
unique_together = [['app_label', 'model']]
def __str__(self):
return self.app_labeled_name

View File

@ -29,7 +29,7 @@ class Migration(migrations.Migration):
('sites', models.ManyToManyField(to='sites.Site', verbose_name='sites')),
],
options={
'ordering': ('url',),
'ordering': ['url'],
'db_table': 'django_flatpage',
'verbose_name': 'flat page',
'verbose_name_plural': 'flat pages',

View File

@ -30,7 +30,7 @@ class FlatPage(models.Model):
db_table = 'django_flatpage'
verbose_name = _('flat page')
verbose_name_plural = _('flat pages')
ordering = ('url',)
ordering = ['url']
def __str__(self):
return "%s -- %s" % (self.url, self.title)

View File

@ -29,7 +29,7 @@ class Migration(migrations.Migration):
)),
],
options={
'ordering': ('old_path',),
'ordering': ['old_path'],
'unique_together': {('site', 'old_path')},
'db_table': 'django_redirect',
'verbose_name': 'redirect',

View File

@ -22,8 +22,8 @@ class Redirect(models.Model):
verbose_name = _('redirect')
verbose_name_plural = _('redirects')
db_table = 'django_redirect'
unique_together = (('site', 'old_path'),)
ordering = ('old_path',)
unique_together = [['site', 'old_path']]
ordering = ['old_path']
def __str__(self):
return "%s ---> %s" % (self.old_path, self.new_path)

View File

@ -18,7 +18,7 @@ class Migration(migrations.Migration):
('name', models.CharField(max_length=50, verbose_name='display name')),
],
options={
'ordering': ('domain',),
'ordering': ['domain'],
'db_table': 'django_site',
'verbose_name': 'site',
'verbose_name_plural': 'sites',

View File

@ -91,7 +91,7 @@ class Site(models.Model):
db_table = 'django_site'
verbose_name = _('site')
verbose_name_plural = _('sites')
ordering = ('domain',)
ordering = ['domain']
def __str__(self):
return self.domain

View File

@ -282,6 +282,11 @@ Miscellaneous
* :tfilter:`floatformat` template filter now outputs (positive) ``0`` for
negative numbers which round to zero.
* :attr:`Meta.ordering <django.db.models.Options.ordering>` and
:attr:`Meta.unique_together <django.db.models.Options.unique_together>`
options on models in ``django.contrib`` modules that were formerly tuples are
now lists.
.. _deprecated-features-3.1:
Features deprecated in 3.1