From de6c9c70549010fc39509f9ef3f6a62ada870318 Mon Sep 17 00:00:00 2001 From: Alex Morega Date: Fri, 26 Aug 2022 17:10:27 +0300 Subject: [PATCH] Refs #30947 -- Changed tuples to lists where appropriate. --- django/contrib/admin/models.py | 4 +- docs/intro/tutorial07.txt | 4 +- docs/ref/contrib/admin/filters.txt | 22 +++--- docs/ref/contrib/admin/index.txt | 90 +++++++++++------------ docs/ref/contrib/flatpages.txt | 12 +-- docs/ref/contrib/gis/serializers.txt | 2 +- docs/ref/contrib/postgres/constraints.txt | 4 +- docs/ref/contrib/syndication.txt | 6 +- docs/ref/models/instances.txt | 4 +- docs/topics/auth/customizing.txt | 38 +++++----- docs/topics/auth/default.txt | 2 +- docs/topics/db/models.txt | 4 +- docs/topics/forms/media.txt | 44 +++++------ docs/topics/forms/modelforms.txt | 44 +++++------ docs/topics/serialization.txt | 2 +- docs/topics/testing/tools.txt | 2 +- 16 files changed, 142 insertions(+), 142 deletions(-) diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index 7ff04102a7..021984160a 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -14,11 +14,11 @@ ADDITION = 1 CHANGE = 2 DELETION = 3 -ACTION_FLAG_CHOICES = ( +ACTION_FLAG_CHOICES = [ (ADDITION, _("Addition")), (CHANGE, _("Change")), (DELETION, _("Deletion")), -) +] class LogEntryManager(models.Manager): diff --git a/docs/intro/tutorial07.txt b/docs/intro/tutorial07.txt index bd8b3c70ef..9e4279e89f 100644 --- a/docs/intro/tutorial07.txt +++ b/docs/intro/tutorial07.txt @@ -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 `: @@ -214,7 +214,7 @@ from :doc:`Tutorial 2 `: 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: diff --git a/docs/ref/contrib/admin/filters.txt b/docs/ref/contrib/admin/filters.txt index 0dc119af3f..a3d7bfc9cd 100644 --- a/docs/ref/contrib/admin/filters.txt +++ b/docs/ref/contrib/admin/filters.txt @@ -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`` ============================ @@ -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): """ @@ -95,7 +95,7 @@ and ``parameter_name`` attributes, and override the ``lookups`` and ) class PersonAdmin(admin.ModelAdmin): - list_filter = (DecadeBornListFilter,) + list_filter = [DecadeBornListFilter] .. note:: @@ -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 @@ -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, @@ -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`` diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index e77a00e2db..4da7a9691a 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -249,7 +249,7 @@ subclass:: from django.contrib import admin class AuthorAdmin(admin.ModelAdmin): - list_display = ('name', 'title', 'view_birth_date') + list_display = ['name', 'title', 'view_birth_date'] @admin.display(empty_value='???') def view_birth_date(self, obj): @@ -276,10 +276,10 @@ subclass:: from django.contrib import admin class AuthorAdmin(admin.ModelAdmin): - fields = ('name', 'title') + fields = ['name', 'title'] class AuthorAdmin(admin.ModelAdmin): - exclude = ('birth_date',) + exclude = ['birth_date'] Since the Author model only has three fields, ``name``, ``title``, and ``birth_date``, the forms resulting from the above declarations will @@ -294,7 +294,7 @@ subclass:: :class:`django.contrib.flatpages.models.FlatPage` model as follows:: class FlatPageAdmin(admin.ModelAdmin): - fields = ('url', 'title', 'content') + fields = ['url', 'title', 'content'] In the above example, only the fields ``url``, ``title`` and ``content`` will be displayed, sequentially, in the form. ``fields`` can contain @@ -314,7 +314,7 @@ subclass:: own line:: class FlatPageAdmin(admin.ModelAdmin): - fields = (('url', 'title'), 'content') + fields = [('url', 'title'), 'content'] .. admonition:: Note @@ -346,15 +346,15 @@ subclass:: from django.contrib import admin class FlatPageAdmin(admin.ModelAdmin): - fieldsets = ( + fieldsets = [ (None, { - 'fields': ('url', 'title', 'content', 'sites') + 'fields': ['url', 'title', 'content', 'sites'], }), ('Advanced options', { - 'classes': ('collapse',), - 'fields': ('registration_required', 'template_name'), + 'classes': ['collapse'], + 'fields': ['registration_required', 'template_name'], }), - ) + ] This results in an admin page that looks like: @@ -368,13 +368,13 @@ subclass:: The ``field_options`` dictionary can have the following keys: * ``fields`` - A tuple of field names to display in this fieldset. This key is + A list or tuple of field names to display in this fieldset. This key is required. Example:: { - 'fields': ('first_name', 'last_name', 'address', 'city', 'state'), + 'fields': ['first_name', 'last_name', 'address', 'city', 'state'], } As with the :attr:`~ModelAdmin.fields` option, to display multiple @@ -383,7 +383,7 @@ subclass:: the same line:: { - 'fields': (('first_name', 'last_name'), 'address', 'city', 'state'), + 'fields': [('first_name', 'last_name'), 'address', 'city', 'state'], } ``fields`` can contain values defined in @@ -399,7 +399,7 @@ subclass:: Example:: { - 'classes': ('wide', 'extrapretty'), + 'classes': ['wide', 'extrapretty'], } Two useful classes defined by the default admin site stylesheet are @@ -540,7 +540,7 @@ subclass:: Example:: - list_display = ('first_name', 'last_name') + list_display = ['first_name', 'last_name'] If you don't set ``list_display``, the admin site will display a single column that displays the ``__str__()`` representation of each object. @@ -552,7 +552,7 @@ subclass:: * The name of a model field. For example:: class PersonAdmin(admin.ModelAdmin): - list_display = ('first_name', 'last_name') + list_display = ['first_name', 'last_name'] * A callable that accepts one argument, the model instance. For example:: @@ -561,13 +561,13 @@ subclass:: return ("%s %s" % (obj.first_name, obj.last_name)).upper() class PersonAdmin(admin.ModelAdmin): - list_display = (upper_case_name,) + list_display = [upper_case_name] * A string representing a ``ModelAdmin`` method that accepts one argument, the model instance. For example:: class PersonAdmin(admin.ModelAdmin): - list_display = ('upper_case_name',) + list_display = ['upper_case_name'] @admin.display(description='Name') def upper_case_name(self, obj): @@ -588,7 +588,7 @@ subclass:: return '%d’s' % (self.birthday.year // 10 * 10) class PersonAdmin(admin.ModelAdmin): - list_display = ('name', 'decade_born_in') + list_display = ['name', 'decade_born_in'] A few special cases to note about ``list_display``: @@ -630,7 +630,7 @@ subclass:: ) class PersonAdmin(admin.ModelAdmin): - list_display = ('first_name', 'last_name', 'colored_name') + list_display = ['first_name', 'last_name', 'colored_name'] * As some examples have already demonstrated, when using a callable, a model method, or a ``ModelAdmin`` method, you can customize the column's @@ -654,7 +654,7 @@ subclass:: Or on a field level:: class PersonAdmin(admin.ModelAdmin): - list_display = ('name', 'birth_date_view') + list_display = ['name', 'birth_date_view'] @admin.display(empty_value='unknown') def birth_date_view(self, obj): @@ -678,12 +678,12 @@ subclass:: return 1950 <= self.birthday.year < 1960 class PersonAdmin(admin.ModelAdmin): - list_display = ('name', 'born_in_fifties') + list_display = ['name', 'born_in_fifties'] * The ``__str__()`` method is just as valid in ``list_display`` as any other model method, so it's perfectly OK to do this:: - list_display = ('__str__', 'some_other_field') + list_display = ['__str__', 'some_other_field'] * Usually, elements of ``list_display`` that aren't actual database fields can't be used in sorting (because Django does all the sorting @@ -711,7 +711,7 @@ subclass:: ) class PersonAdmin(admin.ModelAdmin): - list_display = ('first_name', 'colored_first_name') + list_display = ['first_name', 'colored_first_name'] The above will tell Django to order by the ``first_name`` field when trying to sort by ``colored_first_name`` in the admin. @@ -731,7 +731,7 @@ subclass:: author = models.ForeignKey(Person, on_delete=models.CASCADE) class BlogAdmin(admin.ModelAdmin): - list_display = ('title', 'author', 'author_first_name') + list_display = ['title', 'author', 'author_first_name'] @admin.display(ordering='author__first_name') def author_first_name(self, obj): @@ -766,7 +766,7 @@ subclass:: return self.first_name + ' ' + self.last_name class PersonAdmin(admin.ModelAdmin): - list_display = ('full_name',) + list_display = ['full_name'] Note that ``@property`` must be above ``@display``. If you're using the old way -- setting the display-related attributes directly rather than @@ -819,13 +819,13 @@ subclass:: linked on the change list page:: class PersonAdmin(admin.ModelAdmin): - list_display = ('first_name', 'last_name', 'birthday') - list_display_links = ('first_name', 'last_name') + list_display = ['first_name', 'last_name', 'birthday'] + list_display_links = ['first_name', 'last_name'] In this example, the change list page grid will have no links:: class AuditEntryAdmin(admin.ModelAdmin): - list_display = ('timestamp', 'message') + list_display = ['timestamp', 'message'] list_display_links = None .. _admin-list-editable: @@ -892,7 +892,7 @@ subclass:: ``select_related`` as parameters. For example:: class ArticleAdmin(admin.ModelAdmin): - list_select_related = ('author', 'category') + list_select_related = ['author', 'category'] will call ``select_related('author', 'category')``. @@ -942,7 +942,7 @@ subclass:: fields it should prepopulate from:: class ArticleAdmin(admin.ModelAdmin): - prepopulated_fields = {"slug": ("title",)} + prepopulated_fields = {"slug": ["title"]} When set, the given fields will use a bit of JavaScript to populate from the fields assigned. The main use for this functionality is to @@ -1045,7 +1045,7 @@ subclass:: ``ManyToManyField``:: class ArticleAdmin(admin.ModelAdmin): - raw_id_fields = ("newspaper",) + raw_id_fields = ["newspaper"] The ``raw_id_fields`` ``Input`` widget should contain a primary key if the field is a ``ForeignKey`` or a comma separated list of values if the field @@ -1081,7 +1081,7 @@ subclass:: from django.utils.safestring import mark_safe class PersonAdmin(admin.ModelAdmin): - readonly_fields = ('address_report',) + readonly_fields = ['address_report'] # description functions like a model field's verbose_name @admin.display(description='Address') @@ -1397,8 +1397,8 @@ templates used by the :class:`ModelAdmin` views: For example, to search by ``name`` and ``age``, you could use:: class PersonAdmin(admin.ModelAdmin): - list_display = ('name', 'age') - search_fields = ('name',) + list_display = ['name', 'age'] + search_fields = ['name'] def get_search_results(self, request, queryset, search_term): queryset, may_have_duplicates = super().get_search_results( @@ -1543,7 +1543,7 @@ templates used by the :class:`ModelAdmin` views: filtering based on add, change, delete, and view permissions:: class MyModelAdmin(admin.ModelAdmin): - inlines = (MyInline,) + inlines = [MyInline] def get_inline_instances(self, request, obj=None): return [inline(self.model, self.admin_site) for inline in self.inlines] @@ -1736,12 +1736,12 @@ templates used by the :class:`ModelAdmin` views: class MyModelAdmin(admin.ModelAdmin): def formfield_for_choice_field(self, db_field, request, **kwargs): if db_field.name == "status": - kwargs['choices'] = ( + kwargs['choices'] = [ ('accepted', 'Accepted'), ('denied', 'Denied'), - ) + ] if request.user.is_superuser: - kwargs['choices'] += (('ready', 'Ready for deployment'),) + kwargs['choices'].append(('ready', 'Ready for deployment')) return super().formfield_for_choice_field(db_field, request, **kwargs) .. admonition:: Note @@ -2063,9 +2063,9 @@ on your ``ModelAdmin``:: class ArticleAdmin(admin.ModelAdmin): class Media: css = { - "all": ("my_styles.css",) + "all": ["my_styles.css"], } - js = ("my_code.js",) + js = ["my_code.js"] The :doc:`staticfiles app ` prepends :setting:`STATIC_URL` (or :setting:`MEDIA_URL` if :setting:`STATIC_URL` is @@ -2283,7 +2283,7 @@ The ``InlineModelAdmin`` class adds or customizes: class BookInline(admin.TabularInline): model = Book - raw_id_fields = ("pages",) + raw_id_fields = ["pages"] .. attribute:: InlineModelAdmin.template @@ -2451,7 +2451,7 @@ so by defining an ``InlineModelAdmin`` object for the relationship:: inlines = [ MembershipInline, ] - exclude = ('members',) + exclude = ['members'] There are two features worth noting in this example. @@ -2518,10 +2518,10 @@ customized using any of the options available to ``InlineModelAdmin`` classes. Now create admin views for the ``Person`` and ``Group`` models:: class PersonAdmin(admin.ModelAdmin): - inlines = (MembershipInline,) + inlines = [MembershipInline] class GroupAdmin(admin.ModelAdmin): - inlines = (MembershipInline,) + inlines = [MembershipInline] Finally, register your ``Person`` and ``Group`` models with the admin site:: diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt index 35eb4f9bc9..b4e0957fc7 100644 --- a/docs/ref/contrib/flatpages.txt +++ b/docs/ref/contrib/flatpages.txt @@ -185,17 +185,17 @@ registering a custom ``ModelAdmin`` for ``FlatPage``:: # Define a new FlatPageAdmin class FlatPageAdmin(FlatPageAdmin): - fieldsets = ( - (None, {'fields': ('url', 'title', 'content', 'sites')}), + fieldsets = [ + (None, {'fields': ['url', 'title', 'content', 'sites']}), (_('Advanced options'), { - 'classes': ('collapse',), - 'fields': ( + 'classes': ['collapse'], + 'fields': [ 'enable_comments', 'registration_required', 'template_name', - ), + ], }), - ) + ] # Re-register FlatPageAdmin admin.site.unregister(FlatPage) diff --git a/docs/ref/contrib/gis/serializers.txt b/docs/ref/contrib/gis/serializers.txt index f3d465c385..17886412a7 100644 --- a/docs/ref/contrib/gis/serializers.txt +++ b/docs/ref/contrib/gis/serializers.txt @@ -42,7 +42,7 @@ Example:: serialize('geojson', City.objects.all(), geometry_field='point', - fields=('name',)) + fields=['name']) Would output:: diff --git a/docs/ref/contrib/postgres/constraints.txt b/docs/ref/contrib/postgres/constraints.txt index 44f1f56db1..b8a744f2b4 100644 --- a/docs/ref/contrib/postgres/constraints.txt +++ b/docs/ref/contrib/postgres/constraints.txt @@ -248,10 +248,10 @@ current/rangetypes.html#RANGETYPES-INCLUSIVITY>`_. For example:: constraints = [ ExclusionConstraint( name='exclude_overlapping_reservations', - expressions=( + expressions=[ (TsTzRange('start', 'end', RangeBoundary()), RangeOperators.OVERLAPS), ('room', RangeOperators.EQUAL), - ), + ], condition=Q(cancelled=False), ), ] diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt index 9a65d7bbc2..429565a23c 100644 --- a/docs/ref/contrib/syndication.txt +++ b/docs/ref/contrib/syndication.txt @@ -556,7 +556,7 @@ This example illustrates all possible attributes and methods for a Returns the feed's categories as iterable over strings. """ - categories = ("python", "django") # Hard-coded list of categories. + categories = ["python", "django"] # Hard-coded list of categories. # COPYRIGHT NOTICE -- One of the following three is optional. The # framework looks for them in this order. @@ -604,7 +604,7 @@ This example illustrates all possible attributes and methods for a Returns a list of items to publish in this feed. """ - items = ('Item 1', 'Item 2') # Hard-coded items. + items = ['Item 1', 'Item 2'] # Hard-coded items. # GET_OBJECT -- This is required for feeds that publish different data # for different URL parameters. (See "A complex example" above.) @@ -870,7 +870,7 @@ This example illustrates all possible attributes and methods for a Returns the categories for every item in the feed. """ - item_categories = ("python", "django") # Hard-coded categories. + item_categories = ["python", "django"] # Hard-coded categories. # ITEM COPYRIGHT NOTICE (only applicable to Atom feeds) -- One of the # following three is optional. The framework looks for them in this diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 71fb880740..5ae34b9a77 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -833,11 +833,11 @@ For example:: from django.db import models class Person(models.Model): - SHIRT_SIZES = ( + SHIRT_SIZES = [ ('S', 'Small'), ('M', 'Medium'), ('L', 'Large'), - ) + ] name = models.CharField(max_length=60) shirt_size = models.CharField(max_length=2, choices=SHIRT_SIZES) diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt index 53db554baf..919080a223 100644 --- a/docs/topics/auth/customizing.txt +++ b/docs/topics/auth/customizing.txt @@ -349,7 +349,7 @@ add it to a ``UserAdmin`` class which is registered with the # Define a new User admin class UserAdmin(BaseUserAdmin): - inlines = (EmployeeInline,) + inlines = [EmployeeInline] # Re-register UserAdmin admin.site.unregister(User) @@ -894,10 +894,10 @@ custom user class. class CustomUserAdmin(UserAdmin): ... fieldsets = UserAdmin.fieldsets + ( - (None, {'fields': ('custom_field',)}), + (None, {'fields': ['custom_field']}), ) add_fieldsets = UserAdmin.add_fieldsets + ( - (None, {'fields': ('custom_field',)}), + (None, {'fields': ['custom_field']}), ) See :ref:`a full example ` for more @@ -1105,7 +1105,7 @@ code would be required in the app's ``admin.py`` file:: class Meta: model = MyUser - fields = ('email', 'date_of_birth') + fields = ['email', 'date_of_birth'] def clean_password2(self): # Check that the two password entries match @@ -1133,7 +1133,7 @@ code would be required in the app's ``admin.py`` file:: class Meta: model = MyUser - fields = ('email', 'password', 'date_of_birth', 'is_active', 'is_admin') + fields = ['email', 'password', 'date_of_birth', 'is_active', 'is_admin'] class UserAdmin(BaseUserAdmin): @@ -1144,24 +1144,24 @@ code would be required in the app's ``admin.py`` file:: # The fields to be used in displaying the User model. # These override the definitions on the base UserAdmin # that reference specific fields on auth.User. - list_display = ('email', 'date_of_birth', 'is_admin') - list_filter = ('is_admin',) - fieldsets = ( - (None, {'fields': ('email', 'password')}), - ('Personal info', {'fields': ('date_of_birth',)}), - ('Permissions', {'fields': ('is_admin',)}), - ) + list_display = ['email', 'date_of_birth', 'is_admin'] + list_filter = ['is_admin'] + fieldsets = [ + (None, {'fields': ['email', 'password']}), + ('Personal info', {'fields': ['date_of_birth']}), + ('Permissions', {'fields': ['is_admin']}), + ] # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin # overrides get_fieldsets to use this attribute when creating a user. - add_fieldsets = ( + add_fieldsets = [ (None, { - 'classes': ('wide',), - 'fields': ('email', 'date_of_birth', 'password1', 'password2'), + 'classes': ['wide'], + 'fields': ['email', 'date_of_birth', 'password1', 'password2'], }), - ) - search_fields = ('email',) - ordering = ('email',) - filter_horizontal = () + ] + search_fields = ['email'] + ordering = ['email'] + filter_horizontal = [] # Now register the new UserAdmin... diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt index 59756c5234..6c8b1fe458 100644 --- a/docs/topics/auth/default.txt +++ b/docs/topics/auth/default.txt @@ -781,7 +781,7 @@ To apply permission checks to :doc:`class-based views class MyView(PermissionRequiredMixin, View): permission_required = 'polls.add_choice' # Or multiple of permissions: - permission_required = ('polls.view_choice', 'polls.change_choice') + permission_required = ['polls.view_choice', 'polls.change_choice'] You can set any of the parameters of :class:`~django.contrib.auth.mixins.AccessMixin` to customize the handling diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt index f984e1b0a5..825d817ccf 100644 --- a/docs/topics/db/models.txt +++ b/docs/topics/db/models.txt @@ -181,11 +181,11 @@ ones: from django.db import models class Person(models.Model): - SHIRT_SIZES = ( + SHIRT_SIZES = [ ('S', 'Small'), ('M', 'Medium'), ('L', 'Large'), - ) + ] name = models.CharField(max_length=60) shirt_size = models.CharField(max_length=1, choices=SHIRT_SIZES) diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt index 7e5a04e3d9..801d233244 100644 --- a/docs/topics/forms/media.txt +++ b/docs/topics/forms/media.txt @@ -56,9 +56,9 @@ Here's an example:: class CalendarWidget(forms.TextInput): class Media: css = { - 'all': ('pretty.css',) + 'all': ['pretty.css'], } - js = ('animations.js', 'actions.js') + js = ['animations.js', 'actions.js'] This code defines a ``CalendarWidget``, which will be based on ``TextInput``. Every time the CalendarWidget is used on a form, that form will be directed @@ -96,8 +96,8 @@ provide two CSS options -- one for the screen, and one for print:: class Media: css = { - 'screen': ('pretty.css',), - 'print': ('newspaper.css',) + 'screen': ['pretty.css'], + 'print': ['newspaper.css'], } If a group of CSS files are appropriate for multiple output media types, @@ -107,9 +107,9 @@ requirements:: class Media: css = { - 'screen': ('pretty.css',), - 'tv,projector': ('lo_res.css',), - 'print': ('newspaper.css',) + 'screen': ['pretty.css'], + 'tv,projector': ['lo_res.css'], + 'print': ['newspaper.css], } If this last CSS definition were to be rendered, it would become the following HTML:: @@ -144,9 +144,9 @@ example above:: >>> class FancyCalendarWidget(CalendarWidget): ... class Media: ... css = { - ... 'all': ('fancy.css',) + ... 'all': ['fancy.css'], ... } - ... js = ('whizbang.js',) + ... js = ['whizbang.js'] >>> w = FancyCalendarWidget() >>> print(w.media) @@ -164,9 +164,9 @@ an ``extend=False`` declaration to the ``Media`` declaration:: ... class Media: ... extend = False ... css = { - ... 'all': ('fancy.css',) + ... 'all': ['fancy.css'], ... } - ... js = ('whizbang.js',) + ... js = ['whizbang.js'] >>> w = FancyCalendarWidget() >>> print(w.media) @@ -195,8 +195,8 @@ be defined in a dynamic fashion:: class CalendarWidget(forms.TextInput): @property def media(self): - return forms.Media(css={'all': ('pretty.css',)}, - js=('animations.js', 'actions.js')) + return forms.Media(css={'all': ['pretty.css']}, + js=['animations.js', 'actions.js']) See the section on `Media objects`_ for more details on how to construct return values for dynamic ``media`` properties. @@ -230,9 +230,9 @@ was ``None``:: >>> class CalendarWidget(forms.TextInput): ... class Media: ... css = { - ... 'all': ('/css/pretty.css',), + ... 'all': ['/css/pretty.css'], ... } - ... js = ('animations.js', 'http://othersite.com/actions.js') + ... js = ['animations.js', 'http://othersite.com/actions.js'] >>> w = CalendarWidget() >>> print(w.media) @@ -277,7 +277,7 @@ outputting the complete HTML ``