Error 404 or 500 when pythondjango accesses static files

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.