0

这是我的网址

url(r'^users/(?P<pk>\d+)/testy/$', views.MyModelUpdate.as_view(model=models.User,
    form_class=forms.UserForm, myVariable='testing'), name='my_update'),

这是我的课堂视图

class MyModelUpdate(UpdateView):


 def get(self, request, *args, **kwargs):
       How can i get myVariable here
4

2 回答 2

1

这应该可以解决问题:

def get(self, request, *args, **kwargs):
     pk=kwargs['pk']
     myVariable=self.kwargs['myVariable']
于 2012-10-10T08:25:51.947 回答
0

编辑

怎么样: def get(self, request, myVariable, *args, **kwargs):

于 2012-10-10T07:52:41.757 回答