Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm + Django 1.3 + STATIC_URL in templates = Unresolved static reference

Tags:

django

pycharm

PyCharm (1.3 and 2 beta) in my Django 1.3 project throws a lot of "unresolved static reference" errors when inspecting my templates for script and style includes.

In an outdated PyCharm doc, I found that a small guide that doesn't work in my situation, because my static files are spread over multiple apps. Adding my static dirs to STATICFILES_DIRS also didn't work.

Dir structure (simplified):
  app1/static/js/file.js
  app1/static/css/file.css
  app2/static/js/otherfile.js
  app2/static/css/otherfile.css
  templates/template.html

­

Template.html:
  <script src="{{ STATIC_URL }}js/file.js"></script>

file.js resolves when I visit the template on localhost, but not in PyCharm.

How do I make static files resolve in PyCharm?

like image 550
Blaise Avatar asked Dec 13 '11 10:12

Blaise


2 Answers

Go to Settings in Pycharm 2.73

Settings >> Project Setting >> Django

Enable the Django support and provide the paths for the three following files:

Project Root
Settings file
Manage.py file

When you have given these informations, close PyCharm and restart it.

like image 122
A.J. Avatar answered Oct 23 '22 18:10

A.J.


PyCharm 2.5 finds my static files again.

The trick is to mark app1/static and app2/static as "Source Root".

STATICFILES_DIRS is not working for me.

like image 7
Blaise Avatar answered Oct 23 '22 18:10

Blaise