Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generic view classes should inherit from TemplateView etc

See original GitHub issue

I’m talking about the classes located in wagtailadmin.views.generic.

They all are inheriting from View. They would be easier to use if inheriting from TemplateView (e.g. adding extra context data with get_context_data).

The Create/Edit/Delete views could also benefit from inheriting at least from FormMixin. Even better if they would inherit from BaseCreateView and so on.

So, any reason why this was not done? I’m willing to do the PR if needed.


Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

Gagarocommented, Jun 1, 2017

Thanks for the response. Here’s what I think about it:

I think they’re an unnecessary and counter-productive abstraction

That’s where I disagree. They separate every logical needs so you only have to override what’s necessary. Right now, in the IndexView, I need to override and copy/paste (because what I need to change is located in the middle of the method) the entire get method, which include getting the data, setting the context and the rendering. All that only to add a single variable to the context. Personally, that is what I call counter-productive.

evolving as needed to accommodate them

Most of what we need would already be handled by the CBV provided by Django. And some of those needs are already (not completely) re-implemented by some classes (,

Generic CBV should be easy to use and with low maintenance for almost every use-case. Right now I need to check at every new Wagtail release that the logic inside these views didn’t changed, otherwise I have to change my own view as well to reflect those changes.

gasmancommented, Jun 16, 2017

Resolved in #3625

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to class-based views - Django documentation
Class-based views provide an alternative way to implement views as Python ... Object oriented techniques such as mixins (multiple inheritance) can be used ......
Read more >
Class based views - Advanced Django Training
The class-based views in Django all extend from the parent class View . This class can be found in django.views.generic.base (code here). The...
Read more >
Django Class-Based Generic Views: tips for beginners (or ...
If you inherit from two classes that both define a foo() method, your new class will use the one from the parent class...
Read more >
How to implement a Django class-based view that is both ...
You're overcomplicating this. FormView - like almost all generic views - already inherits from TemplateView (or rather, from ContextMixin, ...
Read more >
Django Tutorial Part 6: Generic list and detail views
We will be inheriting from an existing generic view function that already ... For Django class-based views we access an appropriate view ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found