Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#14557 closed (wontfix)

Generic View improvment

Reported by: pyrou Owned by: nobody
Component: Generic views Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

Maybe adding a __call__ method to django.views.generic.View — source:django/trunk/django/views/generic/base.py — can be useful

something like

    def __call__(self, request, *args, **kwargs):
        return self.dispatch(request, *args, **kwargs)

it will allow to use a genric View "instance" as a view... (hum.. what can be more logical?)

url(r'^permlist/$', ListView(model=Permission, template_name="default/list.html")), 

in addition to (instead of?) the current View.as_view() "factory"

url(r'^permlist/$', ListView.as_view(model=Permission, template_name="default/list.html")),

The sanity check has also to be moved to the View.__init__() method. Have a look to the attached file

Attachments (2)

base.py (6.6 KB) - added by pyrou 11 years ago.
base.py.diff (1.7 KB) - added by pyrou 11 years ago.

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by pyrou

Attachment: base.py added

Changed 11 years ago by pyrou

Attachment: base.py.diff added

comment:1 Changed 11 years ago by Łukasz Rekucki

Resolution: wontfix
Status: newclosed

Sorry, but I'm going to mark this as won't fix. In summary, what you propose causes assignments to self persist from one request to another(It's also not thread safe). Please see wiki page: http://code.djangoproject.com/wiki/ClassBasedViews (and the discussion threads mentioned there) if you want to know more. There is a good reason, why this way of creating views was chosen.

comment:2 Changed 10 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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