Django admin and wagtail static files not found

Hey guys, I’m kind of stumped if anyone could lend a hand. I’ve got a lot experience with django, but I cannot for the life of me figure out what’s going on here.

I have a Django site with wagtail and puput integrated into it. For some reason, in production, the static files are working for the regular site, but not for the django admin or wagtail admin. Any idea what I could be missing?

It’s not a permissions issue, as the static files appear to be 404 not found.

urlpatterns = [     
path('accounts/', include('allauth.urls')),     
path('', views.home, name='home'),     
path('clubs/', include('clubs.urls', namespace="clubs")),     
path('members/', include('members.urls', namespace="members")),     
path('videos/', include('videos.urls', namespace="videos")),     
path('cms/', include(wagtailadmin_urls)),     
path('documents/', include(wagtaildocs_urls)),     
path('blog/', include(wagtail_urls)),     
path('posts/', include(puput_urls)), 
] +static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

STATICFILES_DIRS = [     os.path.join(BASE_DIR, 'static'), ]  
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') 
STATIC_URL = '/static/' 
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 
MEDIA_URL = '/media/' 

folder structure


After running collectstatic, have you verified that the static files are located in the expected directories? (Is it possible that there’s a permissions issue with how you’re running collectstatic?)

Yeah the files are there, getting collected under the main project directory in staticfiles/ just as I show at the end of the post. Is there a way to see where django is looking for the files at runtime? I don’t think I’ve had to try anything like that before.

That may depend upon what webserver you’re using. Look for a “debug” or “trace” option. (To clarify / expand - the purpose of the collectstatic command and the STATIC configuration options is to get Django out of the practice of serving static files. They’re better served by your nginx / apache / whatever web server.)

Right, the staticfiles directory is separate from my static directory. I’m using nginx, although I’m not sure what you mean by a debug or trace option. Perhaps the nginx setup would help?

server {
    listen 80;
    client_max_body_size 5M;
    return 301 https://$server_name$request_uri;

server {
    listen 443 ssl;
    client_max_body_size 5M;
    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/web/capclub;
    location /media/ {
        root /home/web/capclub;

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;

    ssl_certificate /root/;
    ssl_certificate_key /root/;

Although looking at this, I realize there’s nothing that points specifically to the ‘staticfiles’ directory as opposed to the ‘static’ directory. What’s frustrating about all this is that all the static files for the main site DO work, but the admin and wagtail static files DON’T work. I just don’t understand why it wouldn’t be all or nothing.

To get some debugging information:

Note that if nginx doesn’t have permissions to a directory to see files, it returns a 404, not an error.

Verify that the uid being used by nginx has permissions to the admin and wagtail static directories.

Ok, I got it sorted. So long story short, nginx was going to add ‘static’ to any path I tried to point it to. So I moved my static root to a side directory that ended in ‘static’, and everything came together. I appreciate the help.

That’s because you’re using the root directive in the location. If you use alias instead of root, it doesn’t add the component listed in the location directive to the path.

See the docs for root and alias

Hi there,

Allow me to ask a question that pertains this discussion: i am getting a 403 error when nginx tries to serve the admin static files. I have checked my nginx conf files and my django Would you be so kind as to point the error I am not detecting? Thank you so much in advance.

A 403 is a “forbidden” error. There’s a good chance that nginx doesn’t have read permissions to those files.

Thank you for your answer. I have checked nginx error log and the 403 error is not reflected there. I have checked the permissions on the static folder and are set at 755. Still, when I navigate to /admin (with debug mode on) i get this on the terminal:

Ok, since this is not related directly to the original post, it would be more appropriate to open a new thread to discuss this.

My apologies, I will open a new thread.