summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarun Sharma <varunsharmalive@gmail.com>2016-01-09 17:10:08 +0530
committerTim Graham <timograham@gmail.com>2016-01-11 08:18:44 -0500
commit3d6474e1a50dbaf9684f7fb34bfccb77630f27be (patch)
tree69a388893b2d10c98686053769cea14e92742ec7
parent0bc5cd628042bf0a44df60a93085a4f991a84dfb (diff)
Fixed #25385 -- Allowed importing views.generic.View from views.View.
-rw-r--r--django/views/__init__.py3
-rw-r--r--docs/internals/contributing/writing-code/coding-style.txt2
-rw-r--r--docs/ref/class-based-views/base.txt9
-rw-r--r--docs/releases/1.10.txt3
-rw-r--r--docs/topics/class-based-views/intro.txt6
-rw-r--r--docs/topics/class-based-views/mixins.txt4
-rw-r--r--tests/view_tests/views.py2
7 files changed, 19 insertions, 10 deletions
diff --git a/django/views/__init__.py b/django/views/__init__.py
index e69de29bb2..95b0c6b865 100644
--- a/django/views/__init__.py
+++ b/django/views/__init__.py
@@ -0,0 +1,3 @@
+from django.views.generic.base import View
+
+__all__ = ['View']
diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt
index d560cfed19..5dfe9c00f9 100644
--- a/docs/internals/contributing/writing-code/coding-style.txt
+++ b/docs/internals/contributing/writing-code/coding-style.txt
@@ -125,7 +125,7 @@ Imports
* Use convenience imports whenever available. For example, do this::
- from django.views.generic import View
+ from django.views import View
instead of::
diff --git a/docs/ref/class-based-views/base.txt b/docs/ref/class-based-views/base.txt
index e477fd1ea4..dd8a81d800 100644
--- a/docs/ref/class-based-views/base.txt
+++ b/docs/ref/class-based-views/base.txt
@@ -19,7 +19,12 @@ View
.. class:: django.views.generic.base.View
The master class-based base view. All other class-based views inherit from
- this base class.
+ this base class. It isn't strictly a generic view and thus can also be
+ imported from ``django.views``.
+
+ .. versionchanged:: 1.10
+
+ The ability to import from ``django.views`` was added.
**Method Flowchart**
@@ -30,7 +35,7 @@ View
**Example views.py**::
from django.http import HttpResponse
- from django.views.generic import View
+ from django.views import View
class MyView(View):
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index 830f11b66d..33ca4bd12c 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -208,7 +208,8 @@ Forms
Generic Views
^^^^^^^^^^^^^
-* ...
+* The :class:`~django.views.generic.base.View` class can now be imported from
+ ``django.views``.
Internationalization
^^^^^^^^^^^^^^^^^^^^
diff --git a/docs/topics/class-based-views/intro.txt b/docs/topics/class-based-views/intro.txt
index 5e3351e90c..45ffe5b635 100644
--- a/docs/topics/class-based-views/intro.txt
+++ b/docs/topics/class-based-views/intro.txt
@@ -71,7 +71,7 @@ something like::
In a class-based view, this would become::
from django.http import HttpResponse
- from django.views.generic import View
+ from django.views import View
class MyView(View):
def get(self, request):
@@ -113,7 +113,7 @@ and methods in the subclass. So that if your parent class had an attribute
``greeting`` like this::
from django.http import HttpResponse
- from django.views.generic import View
+ from django.views import View
class GreetingView(View):
greeting = "Good Day"
@@ -199,7 +199,7 @@ A similar class-based view might look like::
from django.http import HttpResponseRedirect
from django.shortcuts import render
- from django.views.generic import View
+ from django.views import View
from .forms import MyForm
diff --git a/docs/topics/class-based-views/mixins.txt b/docs/topics/class-based-views/mixins.txt
index 5212381a65..07b2eda2bc 100644
--- a/docs/topics/class-based-views/mixins.txt
+++ b/docs/topics/class-based-views/mixins.txt
@@ -226,7 +226,7 @@ We'll demonstrate this with the ``Author`` model we used in the
from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.urls import reverse
- from django.views.generic import View
+ from django.views import View
from django.views.generic.detail import SingleObjectMixin
from books.models import Author
@@ -570,7 +570,7 @@ You can of course pass through keyword arguments to
would in your URLconf, such as if you wanted the ``AuthorInterest`` behavior
to also appear at another URL but using a different template::
- from django.views.generic import View
+ from django.views import View
class AuthorDetail(View):
diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py
index f80c7ec76a..9e53c14d5b 100644
--- a/tests/view_tests/views.py
+++ b/tests/view_tests/views.py
@@ -10,13 +10,13 @@ from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import render
from django.template import TemplateDoesNotExist
from django.urls import get_resolver
+from django.views import View
from django.views.debug import (
SafeExceptionReporterFilter, technical_500_response,
)
from django.views.decorators.debug import (
sensitive_post_parameters, sensitive_variables,
)
-from django.views.generic import View
from . import BrokenException, except_args