Search code examples
pythondjangostatic-filesdjango-staticfiles

Django - Static pictures not found


Helo all,

I am running a Django application in development mode. I have collected static files into a /static/images/ directory in my project.

In my template I try to link an example image:

<img src="{{ STATIC_URL }}items/no_image.jpeg"/>
    {{ STATIC_URL }}items/no_image.jpeg

(The bottom line is printing for debug purposes)

The picture shows with a broken link, and the bottom line prints out the correct directory:

 /static/items/no_image.jpeg

Inside my project, I do have the /static/items/no_image.jpeg file.

In my settings.py I have:

STATIC_ROOT = os.path.dirname(__file__)+'/static/'
STATIC_URL = '/static/'

Can anybody help?

Thank you !


Solution

  • Found out the problem. The problem was I was using the wrong directory. STATIC_URL was named /site_media/ when it should be /static/. Changed it and everything now works clear as water...