Python django access static file 404 or 500 error

Source: Internet
Author: User
the content method under the Django Static folder does not appear 404 500 error

Need to check your settings file to make sure you have the content

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 Django Project settings file that the project was launched with Eclipse is equal to True, the static file can be accessed? That's not quite clear.

If you need to deploy to a Web site, you need to configure static file mappings in Apache

<virtualhost *:80>   ServerName www.mydjangosite.com   serveralias mydjangosite.com   ServerAdmin fake@mydjangosite.com   documentroot/path/to/mydjangosite   <Directory/path/to/mydjangosite>       Options followsymlinks       allowoverride None       Order allow,deny allow from   </Directory>   alias/static//path/to/mydjangosite/static/   <Directory/path/to/mydjangosite/static>       Order Allow, Deny allow from all   </Directory>   # 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</virtualhost>

Thank you for reading, hope to help everyone, thank you for the support of this site!

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.