django-staticfiles

Django can't find static images in templates

我与影子孤独终老i 提交于 2019-12-08 00:42:32
问题 I've looked at pretty much all the examples here and in the documentation and it just isn't working at all So in my settings.py file I have STATIC_ROOT = '/mattr/static/' STATIC_URL = '/mattr/public/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',) TEMPLATE_CONTEXT_PROCESSORS = ('django.core.context_processors.static',) TEMPLATE_DIRS = ('mattr/public', ) Basically everything needed to handle static

Django: Static Image won't load

£可爱£侵袭症+ 提交于 2019-12-07 14:18:10
问题 I have been following the official documentation to the letter, trying some of the advice for related questions on here, and just searching the web in general and I am still having no luck getting one little image to load. I have an image called 'logo.png' and my project hierarchy looks like this: project/ mysite/ app/ __init__.py admin.py models.py urls.py view.py mysite/ __init__.py settings.py urls.py views.py wsgi.py static/ logo.png templates/ index.html calling_image.html Inside

Django: The joined path is located outside of the base path component

对着背影说爱祢 提交于 2019-12-07 13:14:05
问题 i'm using Django 10 and i dont know why after i collect my static files successfuly, when i try to run server in deployment mode(debug=False) it occurs me something like this: When i look for a static file by doing: python manage.py findstatic /static/mysite/js/javascript.js django.core.exceptions.SuspiciousFileOperation: The joined path (/static/mysite/js/javascript.js) is located outside of the base path component (/home/xxxx/.venvs/mysite/local/lib/python2.7/site-packages/django/contrib

Django Debug=False whitenoise not working

浪尽此生 提交于 2019-12-07 10:18:45
问题 I am trying to deploy my fully functional (when local and Debug=True) site to Heroku. When I use the default Django staticfile_storage settings, my site appears live but without any static files (css, images, etc). The admin panel works but it doesn't have any styles either. But, when I try to use Whitenoise, which is what I originally intended, I get a server 500 error. The admin panel will not work then. I can't figure out for the life of me what I am doing wrong. I have tried to model my

Django | joined path is located outside of the base path component {% static img.thumbnail.url %}, Error 400 with whitenoise

ε祈祈猫儿з 提交于 2019-12-07 01:56:55
问题 I've finish my first app in Django and works perfectly, but still have pre-deployment problems since I set DEGUG=False ... Here is just to display an image in a template... T_T I was using this, but now it does'nt work when I use whitenoise to serve my image localy... And it return a Bad Request(400) error... Models.py class GalleryItem(models.Model): thumbnail = models.ImageField(blank=True,upload_to='gallery/thumb') img_wide = models.ImageField(blank=True,upload_to='gallery') template.py {%

Django can't find staticfiles with Debug=False and Allowed_Hosts

最后都变了- 提交于 2019-12-06 22:29:06
问题 Hi all I'm having trouble solving this issue: If I turn DEBUG to False, I can't run manage.py runserver: CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False Then, let's say I add something to ALLOWED_HOSTS: ALLOWED_HOSTS = ['*'] or ALLOWED_HOSTS = ['localhost'] or ALLOWED_HOSTS = ['127.0.0.1', 'localhost'] Now, I can do ´manage.py runserver´ but the staticfiles don't work. Weird. If I turn DEBUG to True, then it works with ALLOWED_HOSTS set to nothing, to localhost or to *. So

You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path

南楼画角 提交于 2019-12-06 15:29:35
I have gone through every other answer and cannot seem to get anything to work for me. I am following a tutorial and trying to push my master branch to heroku and get the error You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path . I am using Django 2.0 and python 3.6.3. The full traceback: remote: -----> $ python manage.py collectstatic --noinput remote: Traceback (most recent call last): remote: File "manage.py", line 15, in <module> remote: execute_from_command_line(sys.argv) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django

django/whitenoise storage backend causes an error

坚强是说给别人听的谎言 提交于 2019-12-06 10:43:05
问题 i've encountered an 500 error when running my django app on heroku on debug off. after using rollbar to get idea why the error was happaning it reported the following: ValueError: The file 'media/img 1.jpg' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f795706f550>. i figured out it has to do with the STATICFILES_STORAGE setting, by removing it and using the default django STATICFILES_STORAGE ='django.contrib.staticfiles.storage

How to make STATIC_URL work in external JS Files (Django)

孤人 提交于 2019-12-06 07:57:37
I am trying to use STATIC_URL in external javascript file. I was expecting the result as it is working in template, but I found that it is not working in external Javascript file. Please also tell me some work around to make STATIC_URL work in javascript file as it will make my project more manageable. Also I am sending many ajax request and i want to have something like url template tag in my JS file. Please let me know if you know solution of any of them. Thanks I use a simple Django app for making Python / Django settings available in javascript. https://github.com/incuna/django-settingsjs

Why are my compressed files on S3 returning a 403 Forbidden error?

一曲冷凌霜 提交于 2019-12-06 05:24:10
I'm using django-compressor and django-storages to serve my compressed files on S3 (using these instructions: http://django_compressor.readthedocs.org/en/latest/remote-storages/#using-staticfiles ). It works great initially after running the "compress" management command, but after about one hour the compressed css and js files return a 403 Forbidden error even though I haven't made any changes to the files. I can't seem to isolate the problem, so any help would be appreciated. Here are the settings I am using: COMPRESS_ENABLED = True COMPRESS_URL = "http://mybucket.s3.amazonaws.com/" COMPRESS