django run another class-based view (CBV) in a CBV?

前端 未结 1 574
梦如初夏
梦如初夏 2021-01-06 22:27

so I have a CBV (A), CBV (B), and a url like

regex=r\'^(?P[-\\w]+)/(?P[-\\w]+)\'

I want to read in the slug and app

相关标签:
1条回答
  • 2021-01-06 22:48

    You can call it that way:

    class CBViewA(View):
        def dispatch(self, request, *args, **kwargs):
            if kwargs['slug'] = "some slug":
                return CBViewB.as_view()(request, *args, **kwargs)
            else:
                return super(CBViewA, self).dispatch(request, *args, **kwargs)
    
    0 讨论(0)
提交回复
热议问题