5π
To deploy a production server, you need to set 3 things
- deactivate the DEBUG configuration:
DEBUG = False
This disable all extra function for development.
- define a static root directory in the settings file:
STATIC_ROOT = β/this/is/a/path/to/staticsβ
This, indicate where all the static files should be saved.
- run the command to collect all static files:
python manage.py collectstatic
This saves all statics files in the directory configured by STATIC_ROOT
The official documentation for deployment:
https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/#static-root-and-static-url
0π
I donβt actually solve it yet but you can do as below to solve your issue:
1 β Setup your media and static root:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
2 β Activate your virtual enviroment on cpanel then run this command:
python manage.py collectstatic
3 β After you did that 2 folder will create at root of your app on cpanel
"static" and "media" folder copy both of them into "public_html" directory
4 β go to the setup python app in cpanel and find your app and restart it.
It will solve the issue for me but every time when i upload some picture i should go and just copy the media files into public_html
- [Django]-How to list related objects in Django Rest Framework
- [Django]-Custom filtering in django rest framework
- [Django]-Mod_wsgi (3.4-14) / Apache 2.4.12 / Red Hat (6.7) / Django 1.8.2 hanging under load
- [Django]-How to get access to context from Jinja2 extension
0π
I have this issue for 1 day but I found solution. You can install this two packages dj-static static3 with pip:
$ pip install dj-static static3
then change your wsgi.py file like below:
.
.
.
from dj_static import Cling
.
.
.
application = Cling(get_wsgi_application())