Commit 3f2befc9 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Deprecated django.views.defaults.shortcut.

parent 2f121dfe
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
import warnings

from django.conf.urls import patterns

warnings.warn("django.conf.urls.shortcut will be removed in Django 1.8.",
    PendingDeprecationWarning)

urlpatterns = patterns('django.views',
    (r'^(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'),
)
+6 −7
Original line number Diff line number Diff line
import warnings

from django import http
from django.template import (Context, RequestContext,
                             loader, Template, TemplateDoesNotExist)
@@ -63,12 +65,9 @@ def permission_denied(request, template_name='403.html'):


def shortcut(request, content_type_id, object_id):
    # TODO: Remove this in Django 2.0.
    # This is a legacy view that depends on the contenttypes framework.
    # The core logic was moved to django.contrib.contenttypes.views after
    # Django 1.0, but this remains here for backwards compatibility.
    # Note that the import is *within* this function, rather than being at
    # module level, because we don't want to assume people have contenttypes
    # installed.
    warnings.warn(
        "django.views.defaults.shortcut will be removed in Django 1.8. "
        "Import it from django.contrib.contenttypes.views instead.",
        PendingDeprecationWarning, stacklevel=2)
    from django.contrib.contenttypes.views import shortcut as real_shortcut
    return real_shortcut(request, content_type_id, object_id)
+3 −0
Original line number Diff line number Diff line
@@ -362,6 +362,9 @@ these changes.
* Remove the backward compatible shims introduced to rename the attributes
  ``ChangeList.root_query_set`` and ``ChangeList.query_set``.

* ``django.conf.urls.shortcut`` and ``django.views.defaults.shortcut`` will be
  removed.

* The following private APIs will be removed:

  - ``django.db.close_connection()``
+17 −0
Original line number Diff line number Diff line
@@ -352,3 +352,20 @@ private API, it will go through a regular deprecation path.

Methods that return a ``QuerySet`` such as ``Manager.get_query_set`` or
``ModelAdmin.queryset`` have been renamed to ``get_queryset``.

``shortcut`` view and URLconf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``shortcut`` view was moved from ``django.views.defaults`` to
``django.contrib.contentypes.views`` shortly after the 1.0 release, but the
old location was never deprecated. This oversight was corrected in Django 1.6
and you should now use the new location.

The URLconf ``django.conf.urls.shortcut`` was also deprecated. If you're
including it in an URLconf, simply replace::

    (r'^prefix/', include('django.conf.urls.shortcut')),

with::

    (r'^prefix/(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'django.contrib.contentypes.views'),
+0 −1
Original line number Diff line number Diff line
@@ -330,7 +330,6 @@ itself. It includes a number of other URLconfs::
        (r'^comments/', include('django.contrib.comments.urls')),
        (r'^community/', include('django_website.aggregator.urls')),
        (r'^contact/', include('django_website.contact.urls')),
        (r'^r/', include('django.conf.urls.shortcut')),
        # ... snip ...
    )

Loading