django-staticfiles

collecstatic does not push to files S3

℡╲_俬逩灬. 提交于 2020-05-10 03:34:20
问题 EDIT: I have found that removing import django_heroku from my settings.py file allows me to push my static files to my AWS bucket. When I uncomment import django_heroku , collectstatic then pushes my files to the staticfiles folder. manage.py collectstatic with #import django_heroku : You have requested to collect static files at the destination location as specified in your settings. maange.py collectstatic with import django_heroku : You have requested to collect static files at the

Django doesn't load css file

跟風遠走 提交于 2020-04-18 03:51:30
问题 I tried to search many posts about this problem and any one those couldn't solve my problem sadly and I couldn't understand on some points.This is the post. Django cannot find static files. Need a second pair of eyes, I'm going crazy I guess this is the most similar case with me and someone gave very nice answer for it, but it couldn't solve my problem :/ This is my file set - beerlog - beerlog - settings.py - ... - posting - urls.py - templates - posting - base.html - index.html - post.html

django won't load staticfiles from statifiles_dirs

送分小仙女□ 提交于 2020-03-05 05:50:07
问题 My style.css is placed in appname/static/appname/ . My settings.py has this code: STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static/"), ) And in my base.html I load it like this: {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'appname/style.css' %}"> But the styles are not loading. If I remove STATICFILES_DIRS and change STATIC_URL = '/static/' to STATIC_URL = '/static/appname/' , it works perfectly, but I guess it's not the best practice

django won't load staticfiles from statifiles_dirs

三世轮回 提交于 2020-03-05 05:49:45
问题 My style.css is placed in appname/static/appname/ . My settings.py has this code: STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static/"), ) And in my base.html I load it like this: {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'appname/style.css' %}"> But the styles are not loading. If I remove STATICFILES_DIRS and change STATIC_URL = '/static/' to STATIC_URL = '/static/appname/' , it works perfectly, but I guess it's not the best practice

How to use a remote static file server while developing with django manage.py runserver

扶醉桌前 提交于 2020-02-03 09:43:05
问题 Background: I'm using the Django manage.py runserver for local development. I have the contrib.staticfiles in installed apps and I'm using its {% static %} template tag in my templates. What I try to achieve: For development, I'd like to use an independent server for serving the static files but use the django development server to serve the Django app. So that I could access the page locally on my computer at http://127.0.0.1:8000, but all the static files would be served from another

A Simple View to Display/Render a Static image in Django

天大地大妈咪最大 提交于 2020-01-22 19:43:07
问题 I am trying to find the most efficient way of displaying an image using django's template context loader. I have a static dir within my app which contains the image 'victoryDance.gif' and an empty static root dir at the project level (with settings.py ). assuming the paths within my urls.py and settings.py files are correct. what is the best view? from django.shortcuts import HttpResponse from django.conf import settings from django.template import RequestContext, Template, Context def image1

django findstatic not looking in every directory

泪湿孤枕 提交于 2020-01-17 07:27:07
问题 findstatic has a strange behaviour : On localhost python manage.py findstatic pic/xxx.jpg -v 3 gives me : Found 'pic/xxx.jpg' here: /[...]/myapp/app1/static/pix/xxx.jpg Looking in the following locations: /[...]/myapp/app1/static /[...]/myapp/app2/static /[...]/myapp/app3/static /[...]/env/lib/python3.6/site-packages/django/contrib/admin/static whereas on production it gives me Found 'pic/xxx.jpg' here: /[...]/myapp/app1/static/pic/xxx.jpg Looking in the following locations: /[...]/myapp/app1

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

自古美人都是妖i 提交于 2020-01-13 19:28:32
问题 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 回答1: I use a simple Django

django 1.10 media images don't show

我与影子孤独终老i 提交于 2020-01-13 04:52:49
问题 I have had django media images working in an existing django 1.7 project by adding the following to site urls.py: urlpatterns = patters( url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), ) This url structure doesn't work in django 1.10 and so I changed it to the reccommended here Django MEDIA_URL and MEDIA_ROOT: urlpatterns = [ ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) This fails to render any

Django admin not serving static files on Apache

∥☆過路亽.° 提交于 2020-01-07 02:49:07
问题 I've seen similar questions but they are more than 4 years old and the answers doesn't work anymore. I have a site that works correctly on Apache, except for the admin staticfiles. The staticfiles work fine with Django's runserver. I'm kind of lost here, any advice will help. 回答1: When you serve static files using apache, static folder is supposed to be in your /var/www/html directory. I had gone through same scenario as yours. collectstatic didnt work for me. What I did was, copied static