Opened 13 years ago

Closed 12 years ago

Last modified 7 years ago

#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 sylock, 13 years ago

Cc: sylock added
Type: UncategorizedNew feature

comment:2 by Aymeric Augustin, 13 years ago

Really need little modification to the existing code!

Would you mind attaching the changes you suggest as a diff file? That would make it easier to assess this ticket.

comment:3 by Adrien Lemaire, 13 years ago

Easy pickings: set
Needs documentation: set
Needs tests: set
Owner: changed from nobody to Adrien Lemaire
Triage Stage: UnreviewedAccepted

comment:4 by Adrien Lemaire, 13 years ago

Cc: lemaire.adrien@… added

comment:5 by Adrien Lemaire, 13 years ago

Triage Stage: AcceptedDesign 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 Aymeric Augustin, 12 years ago

Resolution: needsinfo
Status: newclosed

Without code, I'm not sure what changes are requested by this ticket. Please create a patch or a pull request.

comment:7 by Tim Graham, 7 years ago

I accepted a ticket for this in #28331.

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