Custom views parameter depending url


Is there a way to add conditional parameter in views depending the url :?

I have a view which perform exactly the same task for 10 different things. But each should have his own schema.
Because we need to expose the schema in views parameters, I have to make 10 different views with for only difference the schema-name, I think it’s a bit to verbose.

shorter :
Whit url : Route(’/{thing_type}/{customer_id}/’, ‘POST’, my_view ),

def my_view(thing_type: str, customer_id: int, obj: ObjSchema):

I need ObjSchema changes with “thing_type”

I hope it’s clear enough

Thanks for answer



I answer to myself. I found a way to do it whith class BasedViews(:wink:) and closures :

First a dict :
my_schema = {modelname1:schema, modelname2:schema}

next a class instanciated with the model :
ViewsModel1 = MyViews(model1)
ViewsModel2 = MyViews(model2)

The class :

class MyViews:
   def __init__(self, model):
         self.model = model
   def create(self):
      def create_views(id:int, schema: my_shema[], auth:Auth,  blabla: SomeType) --> myschema[]:
           # this is just a simple apistar view
           return myschema[](some_stuff)
   #same thing for ceate/update/delete

   def urls(self):
          return [
              Route('/' + + '/', 'POST', self.create()),
              Route(some other routes)

Then I juste include in urls :

myapp_urls : [

thats all, thanks for your opinion