使用resolve方法,该方法返回一个ResolverMatch对象,该对象有以下方法:
func
args
kwargs
url_name
route
app_name
app_names
namespace
namespaces
view_name
from django.urls import resolve
def index(request):
rm = resolve(request.path)
app_name = rm.app_name
url_name = rm.url_name