-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Description
How might I go about writing a CBV that can be inherited from? I want to make a generic class that just needs the class variables set to populate the default CRUD operations that are in the generic base class.
"First" attempt
cbv_router = APIRouter()
class GenericCBV:
service: Optional[Service] = Depends(None)
model: Optional[Vertex] = Depends(None)
@property
def model_id(self):
return f'{self.model.vertex_label()}_id'
@cbv_router.get('/')
async def get_model_list(self):
return self.service.get(self.model.vertex_label())
router = APIRouter()
router.include_router(cbv_router)
@cbv(router)
class InvalidationController(GenericCBV):
service = Depends(Invalidations)
model = Depends(Invalidation)
I am pretty sure I am either missing something or this isn't possible yet. Thanks!
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested