Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #30947 -- Changed tuples to lists where appropriate. #16003

Merged
merged 1 commit into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions django/contrib/admin/models.py
Expand Up @@ -14,11 +14,11 @@
CHANGE = 2
DELETION = 3

ACTION_FLAG_CHOICES = (
ACTION_FLAG_CHOICES = [
(ADDITION, _("Addition")),
(CHANGE, _("Change")),
(DELETION, _("Deletion")),
)
]


class LogEntryManager(models.Manager):
Expand Down
4 changes: 2 additions & 2 deletions docs/intro/tutorial07.txt
Expand Up @@ -204,7 +204,7 @@ object:

class QuestionAdmin(admin.ModelAdmin):
# ...
list_display = ('question_text', 'pub_date')
list_display = ['question_text', 'pub_date']

For good measure, let's also include the ``was_published_recently()`` method
from :doc:`Tutorial 2 </intro/tutorial02>`:
Expand All @@ -214,7 +214,7 @@ from :doc:`Tutorial 2 </intro/tutorial02>`:

class QuestionAdmin(admin.ModelAdmin):
# ...
list_display = ('question_text', 'pub_date', 'was_published_recently')
list_display = ['question_text', 'pub_date', 'was_published_recently']

Now the question change list page looks like this:

Expand Down
22 changes: 11 additions & 11 deletions docs/ref/contrib/admin/filters.txt
Expand Up @@ -33,13 +33,13 @@ Each specified field should be either a ``BooleanField``, ``CharField``,
``ManyToManyField``, for example::

class PersonAdmin(admin.ModelAdmin):
list_filter = ('is_staff', 'company')
list_filter = ['is_staff', 'company']

Field names in ``list_filter`` can also span relations
using the ``__`` lookup, for example::

class PersonAdmin(admin.UserAdmin):
list_filter = ('company__name',)
list_filter = ['company__name']

Using a ``SimpleListFilter``
============================
Expand Down Expand Up @@ -70,10 +70,10 @@ and ``parameter_name`` attributes, and override the ``lookups`` and
human-readable name for the option that will appear
in the right sidebar.
"""
return (
return [
('80s', _('in the eighties')),
('90s', _('in the nineties')),
)
]

def queryset(self, request, queryset):
"""
Expand All @@ -95,7 +95,7 @@ and ``parameter_name`` attributes, and override the ``lookups`` and
)

class PersonAdmin(admin.ModelAdmin):
list_filter = (DecadeBornListFilter,)
list_filter = [DecadeBornListFilter]

.. note::

Expand Down Expand Up @@ -144,9 +144,9 @@ field name and the second element is a class inheriting from
``django.contrib.admin.FieldListFilter``, for example::

class PersonAdmin(admin.ModelAdmin):
list_filter = (
list_filter = [
('is_staff', admin.BooleanFieldListFilter),
)
]

Here the ``is_staff`` field will use the ``BooleanFieldListFilter``. Specifying
only the field name, fields will automatically use the appropriate filter for
Expand All @@ -159,9 +159,9 @@ You can limit the choices of a related model to the objects involved in
that relation using ``RelatedOnlyFieldListFilter``::

class BookAdmin(admin.ModelAdmin):
list_filter = (
list_filter = [
('author', admin.RelatedOnlyFieldListFilter),
)
]

Assuming ``author`` is a ``ForeignKey`` to a ``User`` model, this will
limit the ``list_filter`` choices to the users who have written a book,
Expand All @@ -172,9 +172,9 @@ filter on both empty strings and nulls, depending on what the field
allows to store::

class BookAdmin(admin.ModelAdmin):
list_filter = (
list_filter = [
('title', admin.EmptyFieldListFilter),
)
]

By defining a filter using the ``__in`` lookup, it is possible to filter for
any of a group of values. You need to override the ``expected_parameters``
Expand Down