在我的函数中,如果存在一个字典(作为参数传入),则向它添加另一个字典,或者将它用作字典。(此处为相关词典)
def some_view(request, form_class, template, success_url, context=None):
..........
if context is not None:
context.update({'form': form})
else:
context = {'form': form}
return render(request, template, context)
这很好,但使用
context = context.update({'form': form}) if context is not None else {'form': form}
由于某种原因失败,因为上下文返回为None?你知道吗
你要找的成语很简单
相关问题 更多 >
编程相关推荐