且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

来自另一个应用程序的 django 模板 url

更新时间:2023-01-08 10:22:38

当在来自不同应用程序的 URL 上调用 reverse() 时,你应该使用它的命名空间"版本,就像这样:

When calling reverse() on an URL that comes from a different application, you should use its "namespaced" version, like so:

{% url 'app_name:app_url' %}

在您的具体情况下,这转化为:

In your specific case, that translates to:

{% url 'picture:upload_image' %}