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.