1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #23276 -- Deprecated passing views as strings to url().

This commit is contained in:
Tim Graham
2014-08-12 10:54:42 -04:00
parent 2003cb23d4
commit a9fd740d22
28 changed files with 207 additions and 182 deletions

View File

@@ -2571,10 +2571,12 @@ your URLconf. Specifically, add these four patterns:
.. code-block:: python
url(r'^admin/password_reset/$', 'django.contrib.auth.views.password_reset', name='admin_password_reset'),
url(r'^admin/password_reset/done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),
url(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete', name='password_reset_complete'),
from django.contrib.auth import views as auth_views
url(r'^admin/password_reset/$', auth_views.password_reset, name='admin_password_reset'),
url(r'^admin/password_reset/done/$', auth_views.password_reset_done, name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', auth_views.password_reset_confirm, name='password_reset_confirm'),
url(r'^reset/done/$', auth_views.password_reset_complete, name='password_reset_complete'),
(This assumes you've added the admin at ``admin/`` and requires that you put
the URLs starting with ``^admin/`` before the line that includes the admin app

View File

@@ -54,8 +54,10 @@ Initialization
To activate sitemap generation on your Django site, add this line to your
:doc:`URLconf </topics/http/urls>`::
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap')
from django.contrib.sitemaps.views import sitemap
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
name='django.contrib.sitemaps.views.sitemap')
This tells Django to build a sitemap when a client accesses :file:`/sitemap.xml`.
@@ -277,6 +279,7 @@ Here's an example of a :doc:`URLconf </topics/http/urls>` using both::
from django.conf.urls import url
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from django.contrib.sitemaps.views import sitemap
from blog.models import Entry
info_dict = {
@@ -294,8 +297,8 @@ Here's an example of a :doc:`URLconf </topics/http/urls>` using both::
# ...
# the sitemap
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
]
.. _URLconf: ../url_dispatch/
@@ -311,8 +314,11 @@ the sitemap. For example::
# sitemaps.py
from django.contrib import sitemaps
from django.contrib.sitemaps.views import sitemap
from django.core.urlresolvers import reverse
from . import views
class StaticViewSitemap(sitemaps.Sitemap):
priority = 0.5
changefreq = 'daily'
@@ -332,12 +338,12 @@ the sitemap. For example::
}
urlpatterns = [
url(r'^$', 'views.main', name='main'),
url(r'^about/$', 'views.about', name='about'),
url(r'^license/$', 'views.license', name='license'),
url(r'^$', views.main, name='main'),
url(r'^about/$', views.about, name='about'),
url(r'^license/$', views.license, name='license'),
# ...
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap')
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
name='django.contrib.sitemaps.views.sitemap')
]

View File

@@ -78,7 +78,7 @@ The ``optional_dictionary`` and ``optional_name`` parameters are described in
static()
--------
.. function:: static.static(prefix, view='django.views.static.serve', **kwargs)
.. function:: static.static(prefix, view=django.views.static.serve, **kwargs)
Helper function to return a URL pattern for serving files in debug mode::
@@ -89,6 +89,11 @@ Helper function to return a URL pattern for serving files in debug mode::
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
.. versionchanged:: 1.8
The ``view`` argument changed from a string
(``'django.views.static.serve'``) to the function.
url()
-----
@@ -111,9 +116,14 @@ function or method. See :ref:`views-extra-options` for an example.
See :ref:`Naming URL patterns <naming-url-patterns>` for why the ``name``
parameter is useful.
The ``prefix`` parameter has the same meaning as the first argument to
``patterns()`` and is only relevant when you're passing a string as the
``view`` parameter.
.. deprecated:: 1.8
Support for string ``view`` arguments is deprecated and will be removed in
Django 2.0. Pass the callable instead.
The ``prefix`` parameter has the same meaning as the first argument to
``patterns()`` and is only relevant when you're passing a string as the
``view`` parameter.
include()
---------