#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)
Change History (4)
by , 14 years ago
by , 14 years ago
Attachment: | base.py.diff added |
---|
comment:1 by , 14 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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.