mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #26013 -- Moved django.core.urlresolvers to django.urls.
Thanks to Tim Graham for the review.
This commit is contained in:
committed by
Tim Graham
parent
df3d5b1d73
commit
16411b8400
@@ -1252,7 +1252,7 @@ subclass::
|
||||
For example::
|
||||
|
||||
from django.contrib import admin
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.urls import reverse
|
||||
|
||||
class PersonAdmin(admin.ModelAdmin):
|
||||
def view_on_site(self, obj):
|
||||
@@ -2883,9 +2883,9 @@ So - if you wanted to get a reference to the Change view for a particular
|
||||
``Choice`` object (from the polls application) in the default admin, you would
|
||||
call::
|
||||
|
||||
>>> from django.core import urlresolvers
|
||||
>>> from django.urls import reverse
|
||||
>>> c = Choice.objects.get(...)
|
||||
>>> change_url = urlresolvers.reverse('admin:polls_choice_change', args=(c.id,))
|
||||
>>> change_url = reverse('admin:polls_choice_change', args=(c.id,))
|
||||
|
||||
This will find the first registered instance of the admin application
|
||||
(whatever the instance name), and resolve to the view for changing
|
||||
@@ -2896,8 +2896,7 @@ that instance as a ``current_app`` hint to the reverse call. For example,
|
||||
if you specifically wanted the admin view from the admin instance named
|
||||
``custom``, you would need to call::
|
||||
|
||||
>>> change_url = urlresolvers.reverse('admin:polls_choice_change',
|
||||
... args=(c.id,), current_app='custom')
|
||||
>>> change_url = reverse('admin:polls_choice_change', args=(c.id,), current_app='custom')
|
||||
|
||||
For more details, see the documentation on :ref:`reversing namespaced URLs
|
||||
<topics-http-reversing-url-namespaces>`.
|
||||
|
||||
@@ -300,13 +300,12 @@ Sitemap for static views
|
||||
|
||||
Often you want the search engine crawlers to index views which are neither
|
||||
object detail pages nor flatpages. The solution is to explicitly list URL
|
||||
names for these views in ``items`` and call
|
||||
:func:`~django.core.urlresolvers.reverse` in the ``location`` method of
|
||||
the sitemap. For example::
|
||||
names for these views in ``items`` and call :func:`~django.urls.reverse` in
|
||||
the ``location`` method of the sitemap. For example::
|
||||
|
||||
# sitemaps.py
|
||||
from django.contrib import sitemaps
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.urls import reverse
|
||||
|
||||
class StaticViewSitemap(sitemaps.Sitemap):
|
||||
priority = 0.5
|
||||
|
||||
@@ -53,7 +53,7 @@ This simple example, taken from a hypothetical police beat news site describes
|
||||
a feed of the latest five news items::
|
||||
|
||||
from django.contrib.syndication.views import Feed
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.urls import reverse
|
||||
from policebeat.models import NewsItem
|
||||
|
||||
class LatestEntriesFeed(Feed):
|
||||
|
||||
Reference in New Issue
Block a user