Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#14557 closed (wontfix)

Generic View improvment

Reported by: pyrou Owned by: nobody
Component: Generic views Version: master
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



Maybe adding a __call__ method to django.views.generic.View — source:django/trunk/django/views/generic/ — 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) (6.6 KB) - added by pyrou 10 years ago. (1.7 KB) - added by pyrou 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by pyrou

Attachment: added

Changed 10 years ago by pyrou

Attachment: added

comment:1 Changed 10 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: (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 9 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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