• Register
0 votes
1.7k views

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

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
DATABASES = …

OR

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
2 answers 383 views
383 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
1 vote
1 answer 53 views
53 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 Martin K 6.6k points
0 votes
2 answers 257 views
257 views
Problem : After upgrading it to Django 1.10, I get below error: “TypeError: view must be a callable or a list/tuple in the case of include().” 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 jwilliam 3.9k points
1 vote
1 answer 423 views
423 views
Problem : I am very new to Django. My current task is to store the form field variable with the help of Django cache and I have already added the Django form in my view. I am often facing below error and as I am very new to Django so unable to understand the below ...         form = Formulary() return render(request, 'form.html', {'form' : form}) I am looking for Django expert to fix above error.
asked May 1 stewart 4k points
0 votes
1 answer 420 views
420 views
Probem : I am getting bellow error new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
asked Nov 7, 2019 peterlaw 6.9k points