Fixed #26013 -- Moved django.core.urlresolvers to django.urls.

Thanks to Tim Graham for the review.
This commit is contained in:
Marten Kenbeek 2015-12-30 16:51:16 +01:00 committed by Tim Graham
parent df3d5b1d73
commit 16411b8400
117 changed files with 961 additions and 922 deletions

View file

@ -56,7 +56,7 @@ To get from a URL to a view, Django uses what are known as 'URLconfs'. A
URLconf maps URL patterns (described as regular expressions) to views.
This tutorial provides basic instruction in the use of URLconfs, and you can
refer to :mod:`django.core.urlresolvers` for more information.
refer to :mod:`django.urls` for more information.
Writing more views
==================

View file

@ -71,7 +71,7 @@ create a real version. Add the following to ``polls/views.py``:
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.urls import reverse
from .models import Choice, Question
# ...
@ -124,13 +124,13 @@ This code includes a few things we haven't covered yet in this tutorial:
POST data. This tip isn't specific to Django; it's just good Web
development practice.
* We are using the :func:`~django.core.urlresolvers.reverse` function in the
* We are using the :func:`~django.urls.reverse` function in the
:class:`~django.http.HttpResponseRedirect` constructor in this example.
This function helps avoid having to hardcode a URL in the view function.
It is given the name of the view that we want to pass control to and the
variable portion of the URL pattern that points to that view. In this
case, using the URLconf we set up in :doc:`Tutorial 3 </intro/tutorial03>`,
this :func:`~django.core.urlresolvers.reverse` call will return a string like
this :func:`~django.urls.reverse` call will return a string like
::
'/polls/3/results/'
@ -264,7 +264,7 @@ views and use Django's generic views instead. To do so, open the
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.views import generic
from .models import Choice, Question

View file

@ -362,7 +362,7 @@ With that ready, we can ask the client to do some work for us::
404
>>> # on the other hand we should expect to find something at '/polls/'
>>> # we'll use 'reverse()' rather than a hardcoded URL
>>> from django.core.urlresolvers import reverse
>>> from django.urls import reverse
>>> response = client.get(reverse('polls:index'))
>>> response.status_code
200
@ -447,7 +447,7 @@ Add the following to ``polls/tests.py``:
.. snippet::
:filename: polls/tests.py
from django.core.urlresolvers import reverse
from django.urls import reverse
and we'll create a shortcut function to create questions as well as a new test
class: