Answer to question 1:
Put the static files for the particular app in the app's folder, not the project's 'static' folder.
/project/
/polls/
/static/
/polls/
foobar.css
foobar.js
/templates/
/polls/
vote.html
/static/
specific-to-the-project.js
/templates/
specific-to-the-project.html
base.html
Key thing being that you have a static
folder in your app's folder and it has a folder in it with the same name as your app.
When you run collectstatic
it will collect all of the files found in these folders.
Note, when referencing the files you will do something like...
{% load staticfiles %}
{% static 'app/foobar.css' %}
Answer to question 2:
When you run collectstatic
it will gather all of the files and copy them over to one central location which is specified by the STATIC_ROOT
setting.
Answer to question 3:
No, because you don't work on the files that are in the STATIC_ROOT
. You only work on the files in their original location, then run collectstatic
when you are ready.
Answer to question 4:
You could do a sym link..
Really though, that is what the staticfiles app is for. I suggest adapting it and reading about it here: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/
Update answering comment
Best practice is to do this /<project_root>/polls/static/polls/foobar.css
instead of /<project_root>/polls/static/foobar.css
. Then from your template access foobar.css via {% static 'polls/foobar.css' %}
instead of {% static 'foobar.css' %}
. See the example below.
Example
Before you run collectstatic
/<project_root>
/polls
views.py
urls.py
...
/templates
vote.html
...
/static
/polls
foobar.css
foobar.js
/otherapp
views.py
urls.py
...
/templates
hello.html
...
/static
foobar.css
foobar.js
/<static_root>
(empty)
After you run collectstatic
/<project_root>
/polls
views.py
urls.py
...
/templates
vote.html
...
/static
/polls
foobar.css
foobar.js
/otherapp
views.py
urls.py
...
/templates
hello.html
...
/static
foobar.css
foobar.js
/<static_root>
foobar.css
foobar.js
/polls
foobar.css
foobar.js
The contents of the static folder in each app are copied into the STATIC_ROOT directory.
You risk filename collisions by putting your files directly in the static folder vs adding one more directory and putting them in there.
This is more important when you are working on an open source project and don't know where the app is going to be installed. But it is also considered best practice :) (It took me a while to adapt it but haven't looked back.)
Also, you do not need to add 'polls/static/polls' to STATICFILES_DIRS as long as 'polls' is listed in your INSTALLED_APPS.