Django后台admin的静态文件缺失问题。

登录Django站点管理时,css和js等静态文件无法加载。始终404。但是访问的路径是正确的。使用 python3 manage.py collectstatic 可以正确运行。
图片说明
图片说明

我的静态文件路径为/root/mysite/static。

setting.py中配置如下:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '/static/')
#STATICFILES_DIRS = [os.path.join(BASE_DIR, 'dist/static'),]

CORS_ALLOW_CREDENTIALS = True

urls.py中配置如下:

urlpatterns = [
    path('xxxx/', admin.site.urls),
    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),#url登录配置
    path('apis/',include('infoCenters.urls', namespace='infoCenter')),
    path('doc', include_docs_urls(title="career")),
    url(r'^media/(?P<path>.*)$', serve, {'document_root':MEDIA_ROOT}),
    url(r'',TemplateView.as_view(template_name="index.html")),
    re_path(‘^stiaic/(?P<path>.*)’,serve,{‘document_root’:settings.STATIC_ROOT}), # 用于处理static里的文件
    # path('API', include(router.urls)),

nginx中配置如下:

server {
        listen      80;
        server_name xxxxxx; 


        # substitute your machine's IP address or FQDN
        charset     utf-8;


        client_max_body_size 75M;   # adjust to taste


        location ^~ /media  {
            alias /root/mysite/media; 

        }

        location ^~ /static {
            alias /root/mysite/static; 

        }


        location / {
            # uwsgi_pass  django;  
            uwsgi_pass  127.0.0.1:8001;#uwigs上的socket也得设置为这个
            include     /root/uwsgi_params; 
            # the uwsgi_params file you installed
        }

        location ~.*(js|css|png|gif|jpg|mp3|ogg)$ {
            root /root/mysite/;
        }

    }

static文件的权限也检查过没问题,想请教一下问题是出在哪里。如何解决

https://blog.csdn.net/wushanyun1989/article/details/56009037