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 Tim Graham, 9 years ago

Have you discussed the idea with anyone? If not, could you please raise it on the DevelopersMailingList to see if there are any objections?

comment:2 by Tim Graham, 9 years ago

Component: Core (URLs)Generic views
Summary: Import of ViewsAllow importing django.views.generic.View from django.views.View

comment:4 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Tim Graham, 9 years ago

Easy pickings: set

comment:6 by Asif Saifuddin Auvi, 9 years ago

anyone working on this? or volunteer needed? I'm interested to work on it :D

comment:7 by Tim Graham, 9 years ago

If there's no activity on a ticket in weeks, it's probably fine to reassign it.

comment:8 by Asif Saifuddin Auvi, 9 years ago

Owner: changed from jambonrose to Asif Saifuddin Auvi
Status: newassigned

comment:9 by Asif Saifuddin Auvi, 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?

comment:10 by Asif Saifuddin Auvi, 9 years ago

+ deprecation warnings needed too for moved classes?

comment:11 by Tim Graham, 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.

in reply to:  11 comment:12 by Asif Saifuddin Auvi, 9 years ago

Replying to timgraham:

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.

that seems much simpler then!!!

comment:13 by Asif Saifuddin Auvi, 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 Asif Saifuddin Auvi, 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 Tim Graham, 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:16 by Asif Saifuddin Auvi, 9 years ago

ok thanks will update accordingly

comment:17 by Asif Saifuddin Auvi, 9 years ago

I guess only release notes and some docs update and squash commit required

comment:18 by Varun Sharma, 9 years ago

Has patch: set

in reply to:  18 ; comment:19 by Asif Saifuddin Auvi, 9 years ago

Replying to varun:

PR: https://github.com/django/django/pull/5951

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.

in reply to:  19 comment:20 by Varun Sharma, 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 :)

comment:21 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 3d6474e1:

Fixed #25385 -- Allowed importing views.generic.View from views.View.

Note: See TracTickets for help on using tickets.
Back to Top