Django Class Based Generic Views URL Variable Passing

后端 未结 1 1609
半阙折子戏
半阙折子戏 2021-02-07 20:53

Question is quite simple.

Let\'s say I have an URL config with line:

url(r\'^models/(?P[0-9]+)/(?P\\d+)/$\', \'Group\'         


        
1条回答
  •  感情败类
    2021-02-07 21:35

    You can access positional arguments in self.args and name-based arguments in self.kwargs.

    class Group(ListView): 
    
        def get_queryset(self):
            model_group_id=self.kwargs['model_group_id']
            ...
    

    See the docs for more info.

    0 讨论(0)
提交回复
热议问题