Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将额外参数发送到include中的django routes_Python_Django - Fatal编程技术网

Python 将额外参数发送到include中的django routes

Python 将额外参数发送到include中的django routes,python,django,Python,Django,这是一种向包含中的所有路由发送额外参数的方法 我正在这样做,并且工作: path('<str:lang>/auth/', include('apps.auth.routes'), {'lang': 'en'}, name='auth_routes') path('/auth/',include('apps.auth.routes'),{lang':'en'},name='auth\u routes') 但我想发送该参数的lang字符串,如下所示: path('<str:la

这是一种向包含中的所有路由发送额外参数的方法

我正在这样做,并且工作:

path('<str:lang>/auth/', include('apps.auth.routes'), {'lang': 'en'}, name='auth_routes')
path('/auth/',include('apps.auth.routes'),{lang':'en'},name='auth\u routes')
但我想发送该参数的lang字符串,如下所示:

path('<str:lang>/auth/', include('apps.auth.routes'), {'lang': lang}, name='auth_routes')
path(“/auth/”,包括('apps.auth.routes'),{'lang':lang},name='auth_routes')

我要怎么做才能修复它?

它会将它发送到包含的所有视图,因此您可以通过以下方式实现此功能:

path('<str:lang>/auth/', include('apps.auth.routes'), name='auth_routes')

path('/auth/',include('apps.auth.routes'),name='auth_routes')
只需删除
{'lang':lang}
部分。您是正确的,我的代码中有一个错误。谢谢