我肯定漏了什么傻乎乎的东西。我在一个模板中有一个{% url %},其中操作来自另一个应用程序。它没有起作用,但我不知道使用其他应用程序的视图函数是否有什么不同,或者我只是做了一些傻事。
call/template/call/file.html
call/template/call/file.html
<form action="{% url 'upload_image' %}"></form>
图片/urls.py
from .views import PictureList, PictureCreate, PictureDetail, PictureUpdate, PictureDelete, upload_image
...
url(r'^upload_image/$', upload_image, name='upload_image'),
...
图片/view.py
def upload_image( request ):
print 'IN IMAGE UPLOAD'
print request
我所获得的只有:
NoReverseMatch at /call/4/
Reverse for 'upload_image' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
url.py
还是打错了? - alecxe{% url 'picture:upload_image' %}
会怎样呢? - alecxeaction="{% url 'picture:upload_image' %}"
和url(r'^upload_image/$', upload_image, namespace='picture', name='upload_image'),
但是提示 picture 不是已注册的命名空间。(我以前没有使用过命名空间。) - brechmos