Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Upgraded Bootstrap to 3.4.1 and added CSS source maps#8591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@adamchainz
Copy link
Contributor

@adamchainzadamchainz commentedAug 8, 2022
edited
Loading

Fixes#8587. 3.4.1 has afew changes including an XSS security fix. Adding the CSS source maps will allow DRF to be used with Django 4.1 andManifestStaticFilesStorage.

tim-schilling, wizpig64, benhowes, thmsrmbld, rob4226, and ShlomoCode reacted with thumbs up emoji
@adamchainz
Copy link
ContributorAuthor

Python 3.9 failure is from master.

@KOliver94
Copy link

KOliver94 commentedAug 8, 2022
edited
Loading

@adamchainz I played a bit with the issue and I found out the failing CI is because there are extra tests only for Python 3.9 which use a built version of DRF. The files included during the build are defined inMANIFEST.in and files with.css.map are not included. You need to modify the following line and add*.css.map

recursive-include rest_framework/static *.js *.css *.png *.ico *.eot *.svg *.ttf *.woff *.woff2

You can check the CI runs on my branch:https://github.com/KOliver94/django-rest-framework/pull/1

DE0CH and lovelydinosaur reacted with thumbs up emoji

@adamchainz
Copy link
ContributorAuthor

Thank you, I"ve added toMANIFEST.in.

KOliver94 and DE0CH reacted with thumbs up emoji

@adamchainz
Copy link
ContributorAuthor

Ah I didn't read the logs enough, thefailure on master was due to the missing source map:

 dist run-test: commands[0] | ./runtests.py --no-pkgroot --staticfilesPost-processing 'rest_framework/css/bootstrap-theme.min.css' failed!...INTERNALERROR>     raise ValueError(INTERNALERROR> ValueError: The file 'rest_framework/css/bootstrap-theme.min.css.map' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7fba9b07da60>.

@lovelydinosaur
Copy link
Contributor

Fantastic. Thanks all. 🙏🏼

@tradevize
Copy link

How do I fix this in my project? Cant run collectstatic/

bjackson reacted with thumbs up emoji

@DE0CH
Copy link

I think this fix hasn't been released yet. You can:

  • Wait for the release
  • Downgrade to Django 4.0
  • Use the development version (not recommended)

@adamchainz
Copy link
ContributorAuthor

You can also add source map files, even empty ones, to your project's static folder. Use the right file names:rest_framework/static/rest_framework/css/bootstrap-theme.min.css.map andrest_framework/static/rest_framework/css/bootstrap.min.css.map

shangxiao, jerivas, DylanBohlender, Adegitetaiwo, dunnyk, godman-codes, and Marfullsen reacted with thumbs up emojishangxiao and dunnyk reacted with hooray emoji

@spongyMongy
Copy link

from cli calling heroku config:set DISABLE_COLLECTSTATIC=1 is also an option

ulgens and hiAndrewQuinn reacted with thumbs down emojijerivas reacted with confused emoji

@adamchainz
Copy link
ContributorAuthor

from cli callingheroku config:set DISABLE_COLLECTSTATIC=1 is also an option

This is not a good idea as it will break static assets for most projects.

jerivas, DE0CH, ulgens, hiAndrewQuinn, bjackson, and ShlomoCode reacted with thumbs up emoji

@eabruzzese
Copy link

eabruzzese commentedAug 20, 2022
edited
Loading

For those of you sniffing around for a quick fix, here's a reasonably portable one-liner that will touch.map files for all of the minified CSS provided by DRF:

find"$(python -c'import rest_framework as rf; print(rf.__path__[0])')" -name'*.min.css' -exec touch'{}.map'\;

And if you're justreally itchin' for those sweet, sweet sourcemaps, you can incant the following curse:

(cd"$(python -c'import rest_framework as rf; print(rf.__path__[0])')"&& \  curl -fsSL"https://github.com/encode/django-rest-framework/archive/refs/heads/master.tar.gz" \| tar --extract --gzip --wildcards --strip-components=2'*.map')

Oh, and here's that comment you'll forget to write the moment it starts working:

# HACK: Work around a compatibility issue between Django Rest Framework and Django 4.1##   * Django 4.1 introduces a change to ManifestStaticFilesStorage that replaces CSS source #     map references in static files [0].#   * Django Rest Framework vendors bootstrap CSS files which reference sourcemaps, but #     does not include them in the installed package's static files [1].## TODO: Remove this hack when a new version of Django Rest Framework is released containing#       the fix [1]## [0] https://docs.djangoproject.com/en/4.1/releases/4.1/#django-contrib-staticfiles# [1] https://github.com/encode/django-rest-framework/pull/8591
wizpig64, decibyte, mrharpo, benhowes, akx, hiAndrewQuinn, setnoset, jnns, theletterjeff, philippbosch, and 3 more reacted with heart emojiwizpig64, Noughmad, and jerivas reacted with rocket emoji

@ulgens
Copy link
Contributor

@adamchainz Is there a plan to make a new release with this fix?

@adamchainz
Copy link
ContributorAuthor

Yes,#8599 is where that is happening.

@ulgens
Copy link
Contributor

ulgens commentedSep 9, 2022
edited
Loading

@adamchainz Thank you so much 🌷 I couldn't find that, sorry.

@hiAndrewQuinn
Copy link

hiAndrewQuinn commentedSep 10, 2022
edited
Loading

I ran into this issue as well, while working through@wsvincent 's excellentDjango for APIs book. My fix was somewhat complicated because I was also working within aPoetry environment.

My fix was to downgrade to 4.0.

# Rip Django out, and add a version which will stay at the latest 4.0.whatever.poetry remove djangopoetry add"django==~4.0"# thatnks @adamchainzpoetry update# Check that your repo's Django version is now, in fact, 4.0.whatever.poetry run python -m django --version# Try this again.poetry run python manage.py collectstatic

(For anyone reading in the future, this fix comes around Chapter 4, "Library API", right when we have to start adding inwhitenoise.)

setnoset reacted with heart emoji

@adamchainz
Copy link
ContributorAuthor

@hiAndrewQuinn Downgrading is probably the right approach there. Does the book not reccomend using a specific Django version from the start though? I know Will only advertises the book as updated for Django 4.0 at current.

Also a tip, you don't want to use Django4.0.0, but instead4.0.7, which is the latest release in the 4.0 series. It has a bunch of security and bug fixes. Seethe 4.0.7 release notes, and the previous linked versions. If you don't use the latest release of a given series, you may encounter already-fixed bugs, which is just frustrating.

hiAndrewQuinn reacted with thumbs up emoji

@hiAndrewQuinn
Copy link

He does, and you are correct. I edited my code to reflect that for any future wannabe Djangoists.

theletterjeff added a commit to theletterjeff/gin-rummy-scoresheet that referenced this pull requestSep 19, 2022
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull requestDec 3, 2022
chriswedgwood added a commit to AaLondon/aalondon that referenced this pull requestNov 11, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lovelydinosaurlovelydinosaurAwaiting requested review from lovelydinosaur

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Remove source map references

9 participants

@adamchainz@KOliver94@lovelydinosaur@tradevize@DE0CH@spongyMongy@eabruzzese@ulgens@hiAndrewQuinn

[8]ページ先頭

©2009-2025 Movatter.jp