在基于 django 的项目中,我有一个自定义装饰器的视图:
@login_required
@user_is_project_maintainer
def edit(request, project_key):
...
和实际的自定义装饰器本身:
def user_is_project_maintainer(request):
def decorator(view_func, *args, **kwargs):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, project_key, *args, **kwargs):
project = get_object_or_404(Project, key=project_key)
if (project.maintainer_id != request.user.id) :
return HttpResponseRedirect(reverse('kifos.views.index', args=(project.key,)))
else :
view_func(request, *args, **kwargs)
return _wrapped_view
return decorator
这会导致'function' object has no attribute 'get'
django 内部深处出现异常(in /django/core/handlers/base.py line 188
)。无法弄清楚为什么会这样。有任何想法吗?