Class based views
See original GitHub issueHow to create class based views? Like this
from pyramid.view import (
view_config,
view_defaults
)
@view_defaults(renderer='home.pt')
class TutorialViews:
def __init__(self, request):
self.request = request
@view_config(route_name='home')
def home(self):
return {'name': 'Home View'}
@view_config(route_name='hello')
def hello(self):
return {'name': 'Hello View'}
More info: https://docs.pylonsproject.org/projects/pyramid/en/latest/quick_tutorial/view_classes.html
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Class-based views
A view is a callable which takes a request and returns a response. This can be more than just a function, and Django...
Read more >Django Class-Based-View Inspector -- Classy CBV
Django's class-based generic views provide abstract classes implementing common web development tasks. These are very powerful, and heavily-utilise Python's ...
Read more >Class based views - Advanced Django Training
Django's class-based views provide a object-oriented (OO) way of organizing your view code. Most Django tutorials and training material start developers off ...
Read more >Django : Class Based Views vs Function Based Views
Class-based views provide an alternative way to implement views as Python objects instead of functions. They do not replace function-based views, ...
Read more >DetailView - Class Based Views Django
Class based views are simpler and efficient to manage than function-based views. A function based view with tons of lines of code can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s an approach I use to organize endpoints into classes (mostly so I don’t have to repeat all the dependencies in each signature): https://gist.github.com/dmontagu/87e9d3d7795b14b63388d4b16054f0ff
It can be nice to group resources (user) by class for readability.
Something like: https://flask-restful.readthedocs.io/en/latest/quickstart.html#a-minimal-api