django-storages icon indicating copy to clipboard operation
django-storages copied to clipboard

Django Admin static files with wrong URL (`None` value in URL) google-storage backend

Open AndreLobato opened this issue 11 months ago • 6 comments

I notice this only for the static files for the Django Admin site. All other static files and media URLs seems fine as they return the right URL.

After running ./manage.py collectstatic (success) then ./manage runserver...

Go to Admin site and all the Static files URLs will be as such:

https://storage.googleapis.com/None/admin/css/base.css?X-Goog-Algorithm=...

returning 400.

while the expected would be: https://storage.googleapis.com/{bucket_name}[/{location}]/admin/css/base.css?X-Goog-Algorithm=...

I have only tried with signed URLs as well.

Versions:

Django==5.0.1
django-storages==1.14.2
google-api-core==2.15.0

AndreLobato avatar Mar 20 '24 09:03 AndreLobato

Facing the same issue with Django 4.2. Migrated from the older STATICFILES_STORAGE to the updated STORAGES, and the bucket_name option does not seem to be passed to the storage backend.

varus17 avatar Apr 04 '24 11:04 varus17

looks like duplicate issue, same issue with AWS on bucket_name param https://github.com/jschneier/django-storages/issues/1361#issue-2168604026

tonydattolo avatar Apr 09 '24 20:04 tonydattolo

It sounds like there is maybe an upstream behavior change. Can people confirm they have django.contrib.staticfiles in INSTALLED_APPS?

https://github.com/django/django/blob/85c154da2f07485a1cdc4d886eee4c1a1ef56137/django/templatetags/static.py#L126-L129

jschneier avatar Apr 30 '24 02:04 jschneier

I confirm I do have django.contrib.staticfiles in INSTALLED_APPS

AndreLobato avatar May 01 '24 02:05 AndreLobato

Can you share a bit more details? I strongly suspect you are hitting the comment on this bug that was fixed. In short, are you on 4.2.5+ and also do you have another package that hasn't transitioned to the new STORAGES setting?

https://code.djangoproject.com/ticket/34773#comment:3

jschneier avatar May 01 '24 14:05 jschneier

Ok, thanks for the pointers. I will have another go at this issue and will fill with more details, it's very possible I am using another lib which has not transitioned to new settings.

AndreLobato avatar May 01 '24 21:05 AndreLobato

Please reopen when there is more data, I simply cannot reproduce this or related issues.

jschneier avatar Jul 06 '24 01:07 jschneier

For some reason this is no longer an issue here. Thanks!

AndreLobato avatar Jul 18 '24 22:07 AndreLobato