django-staticfiles

Load static files for all templates in django

风流意气都作罢 提交于 2019-12-03 11:46:02
Is there a way in django to not need the {% load static %} at the top of every template? This question indicates you can factor out common load tags into settings, but doesn't give the particulars you need in this case. As of django 1.9, you can add the following to your template settings: 'builtins': ['django.contrib.staticfiles.templatetags.staticfiles'] For example, the whole template setting might look like this: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context

How to configure django-compressor and django-staticfiles with Amazon's S3?

≡放荡痞女 提交于 2019-12-03 05:38:08
问题 I'm trying to setup django-compressor and django-staticfiles so that the compressed CSS/Javascript and images are served from Amazon's S3. I've managed to setup staticfiles using S3 as the backend so it's collectstatic command sends the files to S3 instead of STATIC_ROOT . However when trying to add django-compressor to the mix is where it all seems to fall apart for me. Following the documentation on setting up remote storages I've created a subclass of the storage backend, boto, so I copied

django static files versioning

懵懂的女人 提交于 2019-12-03 04:46:19
问题 I'm working on some universal solution for problem with static files and updates in it. Example: let's say there was site with /static/styles.css file - and site was used for a long time - so a lot of visitors cached this file in browser Now we doing changes in this css file, and update on server, but some users still have old version (despite modification date returned by server) The obvious solution is to add some version to file /static/styles.css?v=1.1 but in this case developer must

Unable to perform collectstatic

六月ゝ 毕业季﹏ 提交于 2019-12-03 01:34:27
问题 I am new to django ! When I use the command python manage.py collectstatic I get this error django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path But I can successfully run the server . My static files declarations are : STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( ('assets', os.path.join(PROJECT_DIR, '../static')), ) and debug is set to true DEBUG = True How can I fix this? Else am

South + Django 1.4 Database error

可紊 提交于 2019-12-02 22:06:35
I have just installed my Django project on a new system, and installed Django 1.4. However when I try to run manage.py runserver or manage.py syncdb I get this error from South: Validating models... Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x1a67810>> Traceback (most recent call last): File "/home/saul/.virtualenvs/canada/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run self.validate(display_num_errors=True) File "/home/saul/.virtualenvs

How to configure django-compressor and django-staticfiles with Amazon's S3?

你。 提交于 2019-12-02 18:00:49
I'm trying to setup django-compressor and django-staticfiles so that the compressed CSS/Javascript and images are served from Amazon's S3. I've managed to setup staticfiles using S3 as the backend so it's collectstatic command sends the files to S3 instead of STATIC_ROOT . However when trying to add django-compressor to the mix is where it all seems to fall apart for me. Following the documentation on setting up remote storages I've created a subclass of the storage backend, boto , so I copied the example to storage.py . Once I start using this cached backend the files are copied into static

django static files versioning

元气小坏坏 提交于 2019-12-02 17:57:59
I'm working on some universal solution for problem with static files and updates in it. Example: let's say there was site with /static/styles.css file - and site was used for a long time - so a lot of visitors cached this file in browser Now we doing changes in this css file, and update on server, but some users still have old version (despite modification date returned by server) The obvious solution is to add some version to file /static/styles.css?v=1.1 but in this case developer must track changes in this file and manually increase version A second solution is to count the md5 hash of the

Unable to perform collectstatic

爷,独闯天下 提交于 2019-12-02 15:03:54
I am new to django ! When I use the command python manage.py collectstatic I get this error django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path But I can successfully run the server . My static files declarations are : STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( ('assets', os.path.join(PROJECT_DIR, '../static')), ) and debug is set to true DEBUG = True How can I fix this? Else am missing any installation packages ? Try this, PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC

django - Server error loading static files

浪尽此生 提交于 2019-12-02 06:52:36
问题 So im building my own django site. Right now im stuck with loading the statics. im getting the following error in the console: GET http://localhost:8000/static/css/style.css 500 (Internal Server Error) Im trying to load a css file using the static taggs: {{ STATIC_URL }} in my settings i've edited the following: PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) STATIC_ROOT = os.environ.get('STATIC_ROOT',os.path.join(PROJECT_ROOT,"static",)) STATIC_URL = '/static/' STATICFILES_DIRS = (

Django Nginx Browser Caching Configuration

丶灬走出姿态 提交于 2019-12-01 23:40:39
问题 I am trying to configure Nginx to leverage on static file caching on browser. My configuration file is as following server { listen 80; server_name localhost; client_max_body_size 4G; access_log /home/user/webapps/app_env/logs/nginx-access.log; error_log /home/user/webapps/app_env/logs/nginx-error.log; location /static/ { alias /home/user/webapps/app_env/static/; } location /media/ { alias /home/user/webapps/app_env/media/; } ... } When I add in the following caching configuration, the server