how to use static in development with PyCharm?

1,970 views
Skip to first unread message

frocco

unread,
Feb 22, 2013, 11:53:05 AM2/22/13
to django...@googlegroups.com
Hello,

I have my static data mapped to:
STATIC_ROOT = '/wamp/www/static/'

If I hit the app at localhost/app
Everything is ok.

However when I debug in PyCharm, the static data does not map.

My templates use {{ STATIC_URL }}img/....

Thank you

frocco

unread,
Feb 24, 2013, 11:15:19 AM2/24/13
to django...@googlegroups.com
My current settings are:
STATIC_ROOT = '/Applications/djangostack-1.4.4-0/apache2/htdocs/static/'

I am developing now in /Applications/djangostack-1.4.4-0/apps

originally I was developing in the PyCharm Projects Directory
I guess I wanted to know what is a good setup for PyCharm when static and media files are not in the same directory as the project is.
Eventually I will be deploying to webfaction

It seems to be working now.

On Sunday, February 24, 2013 10:43:24 AM UTC-5, Nicholas Duffy wrote:
You mean that in PyCharm, you get the "Unresolved static reference" warning?

Do you have the static files in the static subdirectories of your installed apps or in STATICFILES_DIRS in settings? STATIC_ROOT is meant to be the directory that is used when you run collectstatic in production. With that said, PyCharm seems to find static files there as well on my installation.

W.

unread,
Feb 25, 2013, 3:16:03 AM2/25/13
to django...@googlegroups.com
Hi, I know it may not be direct answer for your question, but try to avoid of hard defined paths.

http://lincolnloop.com/django-best-practices/projects.html

Handling File Paths

One function of your settings is to tell Django where to find things such as your static media and templates. Most likely they’ll already live inside your project. If so, let Python generate the absolute path names for you. This makes your project portable across different environments.

import os
DIRNAME = os.path.dirname(__file__)
# ...
STATIC_ROOT = os.path.join(DIRNAME, 'static')



Dne pátek, 22. února 2013 17:53:05 UTC+1 frocco napsal(a):

Lucianovici

unread,
May 17, 2015, 12:28:56 PM5/17/15
to django...@googlegroups.com
In my case, since I had a bunch of modules inside the settings package, I had to be careful and configure the Django support for PyCharm where the actual static settings are placed, i.e. common.py for my setup.

|-- settings
|   |-- __init__.py
|   |-- codeship.py
|   |-- common.py
|   |-- heroku.py
|   |-- vagrant.py

I hope it will be helpful for somebody, I just burned one hour of frustration going through all the obvious settings that were right.
See attached.
Screenshot 2015-05-17 19.16.56.png
Reply all
Reply to author
Forward
0 new messages