• Register
0 votes
2.6k 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

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
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 518 views
518 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 97 views
97 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 462 views
462 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, 2020 jwilliam 3.9k points
1 vote
1 answer 591 views
591 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, 2020 stewart 4k points
0 votes
1 answer 597 views
597 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
0 votes
1 answer 4.1K views
4.1K views
Problems : I have 2 models, MyCompany and MyProduct, with MyProduct having the ForeignKey to MyCompany class MyProduct(Meta): mycompany = models.ForeignKey( MyCompany, related_name='myproducts', on_delete=models.CASCADE ) I have done the below filtering : mycompany = MyCompany. ... And I am facing below error: The QuerySet value for an exact lookup must be limited to one result using slicing.
asked Dec 16, 2019 alecxe 7.5k points
0 votes
1 answer 29 views
0 votes
1 answer 264 views
264 views
Problem : When I try to run following command: python manage.py updatestats I get the error as below: “TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'” I am unable to figure out ... ) File "/Users/alecxe/project/Dev/project_files/project/main/management/commands/updatestats.py", line 34, in handle unique_visits=display_unique_visits(hostname),)
asked Jan 2, 2020 alecxe 7.5k points
0 votes
1 answer 2.1K views
2.1K views
Problem : I am facing the issue in passing a function as a parameter to another function as follows typeerror: int() argument must be a string, a bytes-like object or a number, not 'nonetype'
asked Nov 18, 2019 peterlaw 6.9k points
0 votes
2 answers 144 views
144 views
I want to run a Django application in PyCharm which works on MySQL DB. I am unable to connect my program to the database. When I am trying to install MySQLclient or MySQL-python I am getting the error: Failed building wheel for MySQLclient Please help me out in connecting my Django program with MySQL database.
asked Oct 24, 2020 psandprop 2.4k points