Why Css and other static files disapear on Django Admin page after deployment to IIS Server

Hi.

My web site has been deployed on IIS Server (Window Server 2019)

I got trouble with missing CSS including other static files on Django Admin page.

The content below describes what I have done.

1. This is my admin page that cannot load any css files at all.
I

For admin section . I use my customized base_site.html in order for changing logo. it is located in
projdec_folder\app\templates\admin as figure below. I don’t know exactly where it is relevant to this problem or not

'Cause I deployed another django project to IIS sevrer without applying customr admin tempate , admin page work well (not issue about static file loading like this case.)

2. More interestingly, every my custom page can load the whole static file completely.
Additionally, If i run with python manage.py runserver http://127.0.0.1:8000/
Admin section is okay, it can be loaded static file/ css perfectly

Below are just my detail and structure in my project. it would be useful to investigate problem.

this is my setting in settings.py , are there any more steps to configure toward this file?

My project folder has 2 locations that contain static folder and web.config as figure shown in below.


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <clear />
      
      <add name="StaticFile" 
      path="*" 
      verb="*" 
      modules="StaticFileModule" 
      resourceType="File" 
      requireAccess="Read" />
    </handlers>
  </system.webServer>
</configuration>



Lastly, I ran the command collectionstatic and add Virtual Directory in order to enable serving static files map a static alias to the static directory already.
the picture show below.

I try to iis reset but nothing better,
I don’t know how to fix this issue.

Anyone can suggest me.

Thank you

I don’t have anything specific to offer as help, but I would look for a couple of things:

  • Check your HTML that is being generated for those static files. You should be able to try to request those files directly.
  • Write your STATIC_ROOT out to a file to verify it’s referencing the right location.
  • Check for something in IIS to allow for more detailed logging regarding errors.
  • Look at the event log for IIS for clues.

Thank

Obviousely , it is all about setting-STATICFILES_DIRS. at that time it refer to static folder in app folderb but actually it must use static folder outside app folder as picture below

I don’t know exactly how to refer this path as static path

https://docs.djangoproject.com/en/3.1/howto/static-files/#deployment
https://docs.djangoproject.com/en/3.1/ref/settings/#std:setting-STATIC_ROOT

this is sampple
STATIC_ROOT = “/var/www/example.com/static/”

I can do it as following step.

  1. running python manage.py collectstatic that copy static path to outside app folder
  2. create virtual app for newly copied static .
    static chage from \ChargeBackWeb\app\static to \ChargeBackWeb\static