This article mainly introduces pythondjango's reference to the 404 or 500 error in accessing static files.
The error 404 500 does not occur for the content methods in the django static folder.
You need to check your settings file to make sure the content is available.
import osPROJECT_ROOT = os.path.dirname(__file__)DEBUG = TrueSTATIC_URL = '/static/'STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'),)STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',)
If the DEBUG value in the settings file of the django project started with eclipse is equal to True, the static file can be accessed? This is not clear.
If you want to deploy it on a web site, you need to configure static file ing in apache.
ServerName www.mydjangosite.com ServerAlias mydjangosite.com ServerAdmin fake@mydjangosite.com DocumentRoot /path/to/mydjangosite
Options FollowSymLinks AllowOverride None Order allow,deny allow from all
Alias /static/ /path/to/mydjangosite/static/
Order allow,deny allow from all
# The following installs the Django WSGI app WSGIDaemonProcess www.mydjangosite.com processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup www.mydjangosite.com WSGIScriptAlias / /path/to/mydjangosite/wsgi.py
Thank you for reading this article. I hope it will help you. thank you for your support for this site!
For more articles about python django's access to static files with errors of 404 or 500, refer to PHP's Chinese website!