是否可以在基于 Django 类的视图中使用装饰器commit_manually ?
问问题
166 次
1 回答
0
The same way you use any other decorator in a class based view.
I personally like decorating the dispatch
method on the class view:
class ManualCommitView(SomeView):
@method_decorator(commit_manually)
def dispatch(self, *args, **kwargs):
return super(ManualCommitView, self).dispatch(*args, **kwargs)
but that's only worth if you plan on reusing the view, otherwise it's easier to just decorate the view in the URLconf
.
于 2013-05-12T18:47:49.633 回答