django-staticfiles

Django StaticFiles and Amazon S3: How to detect modified files?

送分小仙女□ 提交于 2019-11-28 07:42:51
I'm using django staticfiles + django-storages and Amazon S3 to host my data. All is working well except that every time I run manage.py collectstatic the command uploads all files to the server. It looks like the management command compares timestamps from Storage.modified_time() which isn't implemented in the S3 storage from django-storages. How do you guys determine if an S3 file has been modified? I could store file paths and last modified data in my database. Or is there an easy way to pull the last modified data from Amazon? Another option: it looks like I can assign arbitrary metadata

How do I serve media files in a local Django environment?

▼魔方 西西 提交于 2019-11-28 07:31:03
问题 I can upload an image through the admin page, but the image can not be found when I navigate to the url that is generated by django. (404 error) The files are being uploaded to the folder: project_root/media/eventbanner/1/ I have tried multiple solutions but none seem to work for my situation. Django 1.10 is being run local on Ubuntu 16.04. The url I get is: http://localhost:8000/media/eventbanner/1/banner_image.jpg Media root folder is located at: /home/username/xxx/xxx/project_name/media

ValueError: Missing staticfiles manifest entry for 'favicon.ico'

非 Y 不嫁゛ 提交于 2019-11-28 06:47:43
I'm getting a ValueError when running python manage.py test . My project is named fellow_go , and I'm currently working on an App called pickup . Please note that this error is added in a relatively recent commit to Django: Fixed #24452 -- Fixed HashedFilesMixin correctness with nested paths. . ====================================================================== ERROR: test_view_url_exists_at_desired_location (pickup.tests.test_view.HomePageViewTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/sunqingyao

Can I make STATICFILES_DIR same as STATIC_ROOT in Django 1.3?

柔情痞子 提交于 2019-11-28 04:20:45
I'm using Django 1.3 and I realize it has a collectstatic command to collect static files into STATIC_ROOT . Here I have some other global files that need to be served using STATICFILES_DIR . Can I make them use the same dir ? Thanks. No. In fact, the file django/contrib/staticfiles/finders.py even checks for this and raises an ImproperlyConfigured exception when you do so: "The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting" The STATICFILES_DIRS can contain other directories (not necessarily app directories) with static files and these static files will be collected into

Using static files with the django virtual server

南楼画角 提交于 2019-11-27 16:17:21
Questions exactly like this have been asked before, i've read them all and tried to make sense of the official django documentation on the subject but i'm still struggling to use static files on the virtual server. More specifically i'm just trying to get my template, Base.html , to use base.css. My folder structure looks like this: manage.py static/CSS/base.css VergeGreenITEvent_Website/settings.py VergeGreenITEvent_Website/views.py ect VergeGreenITEvent_Website/Webpage_Templates/Base.html (no app folder at the moment, as I was following "The django book" to learn and hadn't gotten to that

Django STATIC_URL is not working

落爺英雄遲暮 提交于 2019-11-27 16:01:29
问题 Django version is 1.4. I had read the official document , and googled my problem. first I had followed the official document Managing static files added this in settings.py : TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ) In my template: <link href

Django staticfiles not found on Heroku (with whitenoise)

允我心安 提交于 2019-11-27 15:06:45
This question seems to be asked several time but I can not fix it. I deployed a django app on production with DEBUG = False . I set my allowed_host . I used {% load static from staticfiles %} to load static files. I exactly write the settings sugested by Heroku doc : BASE_DIR = os.path.dirname(os.path.dirname(__file__)) PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'), ) STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' BUT I

{% load static %} and {% load staticfiles %}: which is preferred?

左心房为你撑大大i 提交于 2019-11-27 15:06:44
问题 I'm not sure what the difference is, it seems like both of them are working. I googled around, and seems like they are pretty much same thing. Just out of curiosity, which one do people use in the field? I read that but still don't know when to use which, and which one people in the field use. Mine works for both of them. At first I thought it's loading static folder but it works for staticfiles too... – 回答1: For the moment (Django 1.9 and earlier), {% load staticfiles %} loads the static

What's the point of Django's collectstatic?

爱⌒轻易说出口 提交于 2019-11-27 11:00:35
This is probably a stupid question, but it's just not clicking in my head. In Django, the convention is to put all of your static files (i.e css, js) specific to your app into a folder called static . So the structure would look like this: mysite/ manage.py mysite/ --> (settings.py, etc) myapp/ --> (models.py, views.py, etc) static/ In mysite/settings.py I have: STATIC_ROOT = 'staticfiles' So when I run the command: python manage.py collectstatic It creates a folder called staticfiles at the root level (so same directory as myapp/) What's the point of this? Isn't it just creating a copy of all

Using static files with the django virtual server

孤人 提交于 2019-11-27 04:07:33
问题 Questions exactly like this have been asked before, i've read them all and tried to make sense of the official django documentation on the subject but i'm still struggling to use static files on the virtual server. More specifically i'm just trying to get my template, Base.html , to use base.css. My folder structure looks like this: manage.py static/CSS/base.css VergeGreenITEvent_Website/settings.py VergeGreenITEvent_Website/views.py ect VergeGreenITEvent_Website/Webpage_Templates/Base.html