#17697 closed New feature (needsinfo)
Implement a new property as list type (like extra_argument) into the ListView class
Reported by: | sylock | Owned by: | Adrien Lemaire |
---|---|---|---|
Component: | Generic views | Version: | 1.3 |
Severity: | Normal | Keywords: | extra_context generic views listview |
Cc: | sylock, lemaire.adrien@… | Triage Stage: | Design decision needed |
Has patch: | no | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Hello,
In the deprecated implementation of generic views (as functions) there was the extra_context list to pass extra arguments to the template.
Since 1.3 and the new implementation of generic views as classes doing the same need the creation of a new customized class which inherits from the ListView class as documented here (in the extra_context chapter): https://docs.djangoproject.com/en/dev/topics/generic-views-migration/#the-context-data-for-object-list-views
It's not pythonic since the new implementation recquire more knowledge of the underlying code, and basicaly, more code to do the same! So it's a regression from my point of view.
It would be really simple to solve it keeping classes implementation by creating a new property as list type. So when instanciate the ListView class we would be able to give the extra variables as arguments.
Really need little modification to the existing code!
Change History (7)
comment:1 by , 13 years ago
Cc: | added |
---|---|
Type: | Uncategorized → New feature |
comment:2 by , 13 years ago
comment:3 by , 13 years ago
Easy pickings: | set |
---|---|
Needs documentation: | set |
Needs tests: | set |
Owner: | changed from | to
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 13 years ago
Cc: | added |
---|
comment:5 by , 13 years ago
Triage Stage: | Accepted → Design decision needed |
---|
I think it would be a good idea to add back the extra_context kwarg, that would allow a user to give the extra context in the urls.py directly for small views.
The extra_context has to be a dict @sylock, you need to specify the key and value for that extra context.
Nevertheless, there might be a good reason why that extra_context field has been removed from the function based views to class based views, so I'd like a core developer to confirm whereas I can work on that new feature or not. I'll have to change several parts of the doc as well, so maybe I'll have to add a note in the release/1.4.txt, or 1.5-alpha-1.txt if we're not gonna add that patch in 1.4.
comment:6 by , 13 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Without code, I'm not sure what changes are requested by this ticket. Please create a patch or a pull request.
Would you mind attaching the changes you suggest as a diff file? That would make it easier to assess this ticket.