Django 以字符串形式获取当前视图的名称 [英] Django Get name of current view as a string
本文介绍了Django 以字符串形式获取当前视图的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以以字符串形式获取 Django 视图的名称?我搜索了很多,但找不到答案.
Is it possible to get the name of Django view in string form? I have searched a lot but could not find the answer.
推荐答案
以上对我不起作用,但我能够通过在 request
上运行 dir
来找到一些解决方案代码>.
The above did not work for me, but I was able to find some solutions by running dir
on request
.
request.resolver_match.view_name
似乎给了我正确的视图名称.
seems to give me the correct name for the view.
这篇关于Django 以字符串形式获取当前视图的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文