• Register
0 votes

Problem :

I want to deploy the Django application to a web, but I face the below error:

“You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path”

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Depending on how you got above error (serving django through the wsgi server or on a command line), you need to check for manage.py or wsgi.py to see what is your name of a default settings file.

If you want to do it manuallly then set the settings to use, use something as shown below :

./manage.py --settings=production

Where the production means any python module.

Please note, your settings file should not import anything the django related. If you want to split the settings for your different environments, then use something as shown below.

A file is settings/base.py

# All the settings are common to all environments
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')

Files like the settings/local.pysettings/production.py

# The Production settings
from settings.base import *
DEBUG = False


Set a STATIC_ROOT setting to your directory from which you would like to serve your files, for e.g.:

STATIC_ROOT = "/var/www/example.com/static/"

The settings which you are using are for the development. Please check the Django docs for the more information here

9 7 4
38,600 points

Related questions

0 votes
1 answer 26 views
Problem: Is it normal to be happen ? how can I fix it : You're using the staticfiles app without having set the static_root setting to a filesystem path..
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1 view
1 view
Problem: I am stuck now .. need some suggestions .. please help me .. The secret_key setting must not be empty.
asked 23 hours ago Ifra 36.4k points
0 votes
2 answers 618 views
Problem : I want to set up the multiple setting files (e.g. Dev, Prod, ..) that include some base settings also. But unable to gain successes in my goal. Whenever I am trying to run my ./manage.py runserver I ... == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cb.settings.development") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
asked Dec 5, 2019 alecxe 7.5k points
0 votes
1 answer 1 view
1 view
Problem: The current path, account/login/, didn't match any of these?What is the problem here?. The redirect works, I have a feeling its in urlpatterns but cannot for the life figure it out. Driving me crazy today. Thanks for the help and sorry for the essay!
asked 4 days ago sumaiya simi 43.9k points
0 votes
1 answer 10 views
Problem: I am currently trying out Django. I use the namespace argument in one of my include()s in urls.py. When I run the server and try to browse, I get this error. File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\conf.py", ... ?P<wine_id>[0-9]+)/$', views.wine_detail, name='wine_detail'), ] What do I pass the app_name as stated in the error message?
asked 5 days ago anika11 32.2k points
1 vote
1 answer 5 views
Problem: I am getting this error.If some expert can put light on it , will be much appreciated. The type t must be a reference type.
asked Mar 25 PkGuy 23.5k points
1 vote
1 answer 140 views
Problem: I have fundamental knowledge of Django. I have learned Django with the help of online tutorials. Recently I have started working on Django. I have recently tried to upgrade my Django to the Django 1.10. Since then I am often facing below error: TypeError: ... ), ] I have only fundamental knowledge about Django so unable to fix the above error. Kindly help me in fixing above Django error.
asked Jun 8, 2020 Martin K 6.6k points
0 votes
2 answers 746 views
Problem : After upgrading it to Django 1.10, I get below error: &ldquo;TypeError: view must be a callable or a list/tuple in the case of include().&rdquo; My urls.py is as below : from django.conf.urls import include, url urlpatterns = [     url(r'^$', 'myapp.views.home' ... r'^contact/$', 'myapp.views.contact'),     url(r'^login/$', 'django.contrib.auth.views.login'), ] How can I fix above error?
asked Jan 23, 2020 jwilliam 3.9k points
0 votes
1 answer 85 views
Problem: commanderror: you must set settings.allowed_hosts if debug is false.
asked Feb 13 Sabbir Hossain 14.6k points
0 votes
1 answer 5 views
Problem: My django website was working in debuging mode but when I put it on the server and turned it to production mode, my website shows me the error: We're sorry, but something went wrong. The issue has been logged for investigation. Please try ... commands python manage.py collectstatic python manage.py migrate python manage.py makemigrations And the problem still exists. What else can I do?
asked 6 days ago anika11 32.2k points