Django template url from another app

I must be missing something stupid. I have {% url%} in a template where the action comes from another application. It doesn’t work, but I don’t know if there’s something different about using the view functions from other applications or if I’m just doing something stupid.

Call / template / call / file.html

    <form action="{% url 'upload_image' %}"></form>

      

photo / urls.py

from .views import PictureList, PictureCreate, PictureDetail, PictureUpdate, PictureDelete, upload_image

...
url(r'^upload_image/$', upload_image, name='upload_image'),
...

      

photo / view.py

def upload_image( request ):
    print 'IN IMAGE UPLOAD'
    print request

      

All I ever get is this:

NoReverseMatch at /call/4/

Reverse for 'upload_image' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

      

+3


source to share


1 answer


When called reverse()

in a URL that comes from another application, you must use the named version of it, for example:

{% url 'app_name:app_url' %}

      



In your specific case, this means:

{% url 'picture:upload_image' %}

      

+2


source







All Articles