django static folder name change

1.8k Views Asked by At

My django project is located at c:/django/project and static folder is at c:/django/project/app/static. I put bootstrap and jquery files to my template under link href="/static/ and src="/static/. But if i change name of folder with static files, they become unavailable. I tried to change settings.py settings and here is the code, but it isn't help also.

STATIC_URL = '/static/

TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')] STATICFILES_DIRS = (os.path.join(BASE_DIR,'/django/lingsite/inputs/static'),) STATIC_ROOT = os.path.join(BASE_DIR, '../static/')

Where static files folder is defined?

2

There are 2 best solutions below

1
On BEST ANSWER

You are doing it wrong, see the docs: https://docs.djangoproject.com/en/1.8/howto/static-files/

this is correct way to locate static files:

{% static "my_app/myexample.jpg" %}

But anyway, you have a misconfigured paths:

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
0
On

You have to make sure the static files get served too.

During development the easiest way is put django.contrib.staticfiles in INSTALLED_APPS then the runserver command will automatically serve your static files. Follow the docs for other methods, and a pointer to the collectstatic command you use for deployment in production.