django-staticfiles

Static files in Django 1.6

末鹿安然 提交于 2019-12-10 16:19:21
问题 I'm probably doing multiple things wrong here because I still can't get static files to work correctly in my development environment despite closely following the tutorial. I have a feeling it's because it works slightly differently in Django 1.6, and I can only find answers for previous versions. Here's my directory structure: mysite ├───app1 ├───mysite │ └───templates ├───resources ├───static │ ├───css │ ├───fonts │ └───js └───app2 My installed apps, to prove I have staticfiles on:

Django not able to find the static files when using django-allauth

元气小坏坏 提交于 2019-12-10 16:06:40
问题 When I use allauth, everything seems to work fine except that Django is now unable to find the static files. Without allauth all the static files are being rendered. the settings for allauth requires to add TEMPLATE_CONTEXT_PROCESSORS = ( "allauth.context_processors.allauth", "allauth.account.context_processors.account" ) I did not have TEMPLATE_CONTEXT_PROCESSORS in my settings file earlier. Is there something that I am missing? How should I solve this problem. When I see the DEBUG console I

Reference Static Images From Javascript in Django

我怕爱的太早我们不能终老 提交于 2019-12-10 15:06:11
问题 So I'm working on a Django project and am trying to figure out how to get Javascript to be able to render images from my static directory. I've modified my settings.py to load static files (images, js, etc.) from myproject/static and my templates from myproject/templates. Now at the top of each of these templates I have the following line: {% load staticfiles %} which allows me to load images like this in the template: <img src="{% static "images/someImage.jpg" %}" width="65" height="36" alt=

Use the same static file into multiple apps in Django

馋奶兔 提交于 2019-12-10 13:24:19
问题 My Django project is divided into several apps, and the static files are stored in each app like this: /Project /foo /static /css /style.css /views.py /models.py /urls.py /bar /static /css /style.css /views.py /models.py /urls.py /urls.py /manage.py /settings.py But I am not sure how to use the same static files into multiple apps. 回答1: This is what the STATICFILES_DIRS setting is for: Your project will probably also have static assets that aren’t tied to a particular app. The STATICFILES

TemplateSyntaxError 'staticfiles' is not a valid tag library'

[亡魂溺海] 提交于 2019-12-10 02:39:02
问题 I'm having a really strange issue trying to get the staticfiles taglib working in my application. I'm essentially getting the following error: 'staticfiles' is not a valid tag library: Template library staticfiles not found, tried django.templatetags.staticfiles,django.contrib.admin.templatetags.staticfiles Here's my template which is throwing this error: {% load staticfiles %} <html> <head> {% block stylesheets %} <link rel="stylesheet" href="{% static "styles/bootstrap-1.2.0.min.css" %}"> {

Using static files in custom 404/500 pages in Django

烂漫一生 提交于 2019-12-09 17:28:11
问题 I would like to use some custom CSS and images on my custom 404/500 pages that I made. Django doesn't include the STATIC_URL variable in those pages though. What would be the best way to accomplish this? I also tried making a custom 404/500 view and rendering an arbitrary HTML file but it didn't work out so great. 回答1: Here's how I would do it: # urls or settings handler500 = 'mysite.views.server_error' # views from django.shortcuts import render def server_error(request): # one of the things

Django: static files in a 404 template

耗尽温柔 提交于 2019-12-08 12:04:15
问题 How to include stylesheets and images into a 404 page template using the default view? I created a 404.html file in the root of the site's templates directory: <!DOCTYPE html> <html> <head> {% load static %} <link rel="stylesheet" href="{% get_static_prefix %}css/404.css" /> </head> <body class="page-404"> <p>Not found.</p> </body> </html> Ironically, the 404.css is not found. The 404.css file is located in one of the apps' static directory. The server is manage.py runserver . On every other

Django 2.2 staticfiles do not work in development

可紊 提交于 2019-12-08 11:15:12
问题 I'm making a new django app where a user can upload images and then they can be displayed on a page. I've read the django docs 10000 times through and I still don't understand why my images aren't loading (DEBUG = True) All my images are going to where they're supposed to be and in the admin in my models django has the right path that leads to the image but it just won't load properly. my setup in settings.py: STATIC_URL = '/static/' STATIC_ROOT = 'static' # live cdn such as AWS S3

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

丶灬走出姿态 提交于 2019-12-08 03:17:00
问题 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:

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

混江龙づ霸主 提交于 2019-12-08 02:53:34
问题 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