Opened 9 years ago
Closed 9 years ago
#25385 closed Cleanup/optimization (fixed)
Allow importing django.views.generic.View from django.views.View
Reported by: | jambonrose | Owned by: | Asif Saifuddin Auvi |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Whenever I talk about class-based views and how their concept is separate from generic views (typically in a class setting), the question I am asked is invariably: if they are different, why do we import View
from django.views.generic
?
To help developers better avoid confusion and better separate the concepts, I would like to change the import of the View
class. Ideally:
from django.views import View
I would furthermore like to move View
from the generic directory into it's own module.
Change History (21)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Component: | Core (URLs) → Generic views |
---|---|
Summary: | Import of Views → Allow importing django.views.generic.View from django.views.View |
comment:4 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 9 years ago
Easy pickings: | set |
---|
comment:6 by , 9 years ago
anyone working on this? or volunteer needed? I'm interested to work on it :D
comment:7 by , 9 years ago
If there's no activity on a ticket in weeks, it's probably fine to reassign it.
comment:8 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:9 by , 9 years ago
Hi tim,
View class need to be moved from generic module to views module, what whould be the module name? base.py? or view.py?
after moving specific classes it will be needed to fix the import in existing all modules/files too. does the contextmixin need to be moved along with VIEW class?
follow-up: 12 comment:11 by , 9 years ago
I think it's enough to add an import for from django.views.generic.base import View
in django/views/__init__.py
. I don't see much gain in moving the code.
comment:12 by , 9 years ago
Replying to timgraham:
I think it's enough to add an import for
from django.views.generic.base import View
indjango/views/__init__.py
. I don't see much gain in moving the code.
that seems much simpler then!!!
comment:13 by , 9 years ago
PR created
https://github.com/django/django/pull/5742
Docs + Release notes needed.
should It be back ported to 1.8 and 1.9?
comment:14 by , 9 years ago
./django/views/init__.py:1:1: F401 'View' imported but unused
Build step 'Execute shell' marked build as failure
Setting status of 3b403668b22bea5315bc1c6fbb8237527d43ebb4 to FAILURE with url http://djangoci.com/job/flake8/6233/ and message: 'Build finished. No test results found.'
Using context: flake8
Finished: FAILURE
Then test should be added too to make the build pass?
comment:15 by , 9 years ago
You can fix the flake8 failure by adding __all__ = ['View']
in that file.
It's a new feature, so it's not a candidate for backport. See our supported versions policy.
comment:17 by , 9 years ago
I guess only release notes and some docs update and squash commit required
follow-up: 19 comment:18 by , 9 years ago
Has patch: | set |
---|
follow-up: 20 comment:19 by , 9 years ago
Replying to varun:
Hi Varun, I've already send a PR and the PR is still open. besides I haven't deassigned the issue yet :) so to avoid duplicate works better to ask the assigned guy first.
comment:20 by , 9 years ago
Replying to auvipy:
Hi !!
I saw your PR and there wasn't any activity or follow up in that from last 18 days. I guess that's a reasonable period to reassign the ticket. There wasn't much of work in this anyway :)
Have you discussed the idea with anyone? If not, could you please raise it on the DevelopersMailingList to see if there are any objections?