diff --git a/django/forms/__init__.py b/django/forms/__init__.py index 5e67122a6a..e6fc03db04 100644 --- a/django/forms/__init__.py +++ b/django/forms/__init__.py @@ -467,7 +467,7 @@ class SelectField(FormField): selected_html = '' if str(value) == str_data: selected_html = ' selected="selected"' - output.append(' ' % (escape(value), selected_html, display_name)) + output.append(' ' % (escape(value), selected_html, escape(display_name))) output.append(' ') return '\n'.join(output) diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py index e42ca36175..f2367d83cb 100644 --- a/django/views/generic/date_based.py +++ b/django/views/generic/date_based.py @@ -86,7 +86,11 @@ def archive_month(request, year, month, queryset, date_field, Templates: ``/_archive_month`` Context: month: - this month + (date) this month + next_month: + (date) the first day of the next month, or None if the next month is in the future + previous_month: + (date) the first day of the previous month object_list: list of objects published in the given month """ @@ -116,6 +120,8 @@ def archive_month(request, year, month, queryset, date_field, c = RequestContext(request, { 'object_list': object_list, 'month': date, + 'next_month': (last_day < datetime.date.today()) and (last_day + datetime.timedelta(days=1)) or None, + 'previous_month': first_day - datetime.timedelta(days=1), }, context_processors) for key, value in extra_context.items(): if callable(value): diff --git a/django/views/static.py b/django/views/static.py index 19b5ec2ab8..ed6ca5f54d 100644 --- a/django/views/static.py +++ b/django/views/static.py @@ -56,13 +56,13 @@ DEFAULT_DIRECTORY_INDEX_TEMPLATE = """ - Index of {{ directory }} + Index of {{ directory|escape }} -

Index of {{ directory }}

+

Index of {{ directory|escape }}

diff --git a/docs/generic_views.txt b/docs/generic_views.txt index b9777139ca..d677a94bb3 100644 --- a/docs/generic_views.txt +++ b/docs/generic_views.txt @@ -190,7 +190,14 @@ The date-based generic functions are: Has the following template context: ``month`` - The given month (a datetime.datetime object) + The given month (a datetime.date object) + ``next_month`` + **New in Django development version.** The first day of the next + month, or None if the next month is in the future (a datetime.date + object) + ``previous_month`` + **New in Django development version.** The first day of the + previous month (a datetime.date object) ``object_list`` List of objects published in the given month