I have spent hours on this and looked everywhere, but wasn't able to figure out, so I beg help from more experienced once.
It is not my first time I am creating a django app, so I referenced what I did before, but nothing helps. I am trying to serve static files using "static" template tag, but it doesn't work.
I am pretty sure I set up everything correctly(following tutorials and my previous projects; i'll provide settings below), but when I run server locally, it can't find my static files. When I replace static template tag with {{STATIC_URL}} tag it works. I even type the direct path in my browser to the static files, all of them work. I get output of CSS and JS files. It is driving me crazy, that the static template tag is not working.
Here are my settings:
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = 'staticfiles'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/w/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
#ADMIN_MEDIA_PREFIX = '/admin/media/'
# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(PROJECT_DIR, 'static/'),
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',)
Btw, i checked the path for static folder and it is correct. I deliberately didn't include the name of the app, so it is there. I also include {%load static from staticfiles%} tag. As i mentioned only static tag isn't working. Please, somebody explain what stupid mistake I am making.
thanks