-
Notifications
You must be signed in to change notification settings - Fork 26
Fixes to media paths #27
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I believe that MEDIA_URL is for user-uploaded media now, so probably django-css shouldn't use MEDIA_URL at all. The current docs on staticfiles say to use STATIC_URL in your templates. Your fix doesn't work for me, I still get: |
|
derek73, you just need to place your css in the static folder or am I mistaken? |
|
which static folder? the css file could be in a static folder in any app if you're using AppDirectoriesFinder or any other place you define by writing a custom finder and adding it to STATICFILES_FINDERS. Need to use staticfiles finders to find the css and js files. This works for me: https://github.com/derek73/django-css/commit/90be97f49411ec2c02ac7c177fcc86da557dd036 Though, I had to set COMPRESS_URL = STATIC_URL in order to make it work. I also had to change my default storage to use the staticfiles storage so that staticfiles could serve the files when DEBUG=True. When DEFAULT_FILE_STORAGE is StaticFilesStorage, DefaultStorageFinder finds things in STATIC_ROOT. Here's my relevant settings. I had to put COMPRESS_OUTPUT_DIR inside my COMPRESS_ROOT because the image urls in the css were not being rewritten to reflect the location of the compressed css file. The above happens to work because I put my site-specific css/img/js in a "site" directory inside "static" in each of my apps. The problem is at compressor/filters/css_default.py line 18. that test should also include a test for if this file is one that is being served by static files and if so, go ahead and do the url rewriting. Not sure I follow how this module works though, so not exactly sure what/where the test should be. |
|
Sorry for being vague. I meant in a place under your STATIC_URL. I've had problems getting staticfiles working reliable with the dev server, so I mostly use runserver it with --nostatic (after running collectstatic and serving the static dir with 'django.views.static.serve') |
|
@derek73: the way I solved it was to remove the check on if the filename started with media_root (all of mine do, after collectstatic has been run). Then, on line 20, I have: This is a little bit hacky: I need to ensure that I only have the string |
|
Needed #33 to make your patch work properly. |
|
Also running into these issues with 1.3, agree that we should probably just nix MEDIA_URL, at least in the 1.3 world. One oddity is why does MEDIA_URL in the context take priority over COMPRESS_URL? Seems like if you explicitly define a COMPRESS_URL that should take precedence. |
|
You might wanna take a look at https://github.com/jezdez/django_compressor/. It now has a precompiler filter with which you can add support for external commands (sass, coffescript etc). Seems to work well and have support for Django 1.3 / staticfiles. |
Some issues with the media paths came up when using django-css with Django 1.3 (beta).