Solution to error code returned by django when accessing static resources css, js, and image

Source: Internet
Author: User
Tags error code django server

The error screenshot is as follows:

All static resource files, including css, js, and image files, cannot be found, and encoding error is reported in the background.

I have tried many methods, including setting DEFATULT_CHARSET = 'utf-8' in settings. py, and also tried to add the following statement to manage. py:
Program code

The code is as follows: Copy code

Reload = reload (sys)
Sys. setdefaultencoding ("cp1251 ")

# In fact, an error is reported here. It seems that python2.7 does not support setdefaultencoding.


In this way, it seems that some problems will be solved, but not all. Some css and js files can be opened, but the image still seems to have a problem. You 'd better find a solution to solve the problem:

Add sitecustomize. py to the C: \ Python27 \ Lib \ site-packages directory. The content of sitecustomize. py is as follows:

Program code

The code is as follows: Copy code

Import sys
Sys. setdefaultencoding ("cp1251 ")


Run django server again. Everything is normal.

Related Article

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.