Solve the Problem of CSS loss when deploying Django admin in Apache

Source: Internet
Author: User

See my other article about how to deploy Django in Apache.

After the deployment is completed, enter the address to open the project. In the project, CSS and JS are used as long as they are not absolute paths.

Go to the admin Management page and find a big white page with no style.

 

Now I will introduce a solution:

In the article on deployment, I introduced that creating an Apache directory under the project path includes configuration for the project.

There is a file apache_django_wsgi.conf, Which is manually created by yourself and contains some Apache configurations for the project. (The same is true if you directly add httpd. conf)

 

Add the following code

1 alias/admin_media C:/python27/lib/Site-packages/Django/contrib/admin/Media
2 <directory "C:/python27/lib/Site-packages/Django/contrib/admin/Media">
3 AllowOverride none
4 options none
5 order allow, deny
6 allow from all
7 </directory>
8 <location "/Media/">
9 sethandler none
10 </location>
11 <locationmatch "\. (JPG | GIF | PNG | TXT | ICO | PDF | CSS | JPEG) $">
12 sethandler none
13 </locationmatch>

Replace the path in your system. Note the alias/admin_media in the document.

Open the setting. py file of your project and make the following changes. The path corresponds to the installation path of your system.

Media_root = 'C:/python27/lib/Site-packages/Django/contrib/admin/media'

Admin_media_prefix = '/admin_media /'

 

Save and restart Apache to view the effect.

 

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.