django-staticfiles

Django Static js files not working

不羁岁月 提交于 2019-12-06 02:02:05
Well my template code. <!DOCTYPE html> <html> <head> {% load staticfiles %} <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript" src="{% static 'website/staffaddproblem.js' %}"></script> <title>Dashboard</title> <link href="{% static 'website/style.css' %}" rel="stylesheet" type="text/css"/> </head> <body> body </body> <html> As you can see it has a css file. which is working properly, but java script file does not work. when i load the page its source looks like this. When i click the link it loads the file too its there its

Django: How can I gzip staticfiles served in dev mode?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 00:00:04
问题 My django.contrib.staticfiles settings seems to be ok as all static files get served as expected. However, eg. /static/*.css files do not get gzipped although I have GZipMiddleware turned on. Fyi. my views html actually does get gzipped, only the files served by the staticfiles app dont. Seems these responses dont go through the middleware chain? 回答1: The trick is to have the development server run with the '--nostatic' flag set: ./manage.py runserver --nostatic . One then can user a url

Django findstatic : No matching file found

♀尐吖头ヾ 提交于 2019-12-05 20:15:43
A while ago, I attempted to use "collectstatic" in Django to serve my static files and failed miserably. Now I am finally trying to get my static files serving correctly in my development environment. I can't figure out what has gone wrong. When I run python manage.py findstatic images/add.png console returns: base path: C:\Projects\AlmondKing\AlmondKing static files dirs: C:\Projects\AlmondKing\AlmondKing\static No matching file found for 'images/add.png'. The directory paths are correct, but it still can't locate my files. I've tried a number of different settings configurations to no avail.

django static file not loading

纵饮孤独 提交于 2019-12-05 20:07:28
I have problem that i done every thing as described in tutorial https://docs.djangoproject.com/en/1.5/intro/tutorial06/ and every thing also running fine but css,images are not showing their effects. Being a new one on django, Suggestions required. thanks for any help. My css file:- li a { color: red; } body { background: white url("images/background.gif") no-repeat right bottom; } url.py file:- from django.conf import settings from django.conf.urls.static import static from django.conf.urls import patterns,url from polls import views urlpatterns = patterns('', url(r'^$', views.IndexView.as

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

喜欢而已 提交于 2019-12-05 19:33:44
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/admin/static) I run this using a virtual env 'mysite'. In settings.py : STATIC_URL = '/static/' STATIC

Django: Static Image won't load

断了今生、忘了曾经 提交于 2019-12-05 19:08:14
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 settings.py I have STATIC_URL = '/static/' Inside calling_image.html I have <img src="/static/logo.png"> My

Django Debug=False whitenoise not working

余生长醉 提交于 2019-12-05 17:36:23
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 settings.py file after Heroku's template: https://github.com/heroku/heroku-django-template , and

Django : Static content not found

痞子三分冷 提交于 2019-12-05 15:26:12
问题 I have been breaking my head over this for a full day but can't figure out the problem. It happened after I copied my project from one machine to another. Settings.py STATIC_URL = '/static/' STATIC_ROOT = 'staticfiles' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), ) Mentioned 'django.contrib.staticfiles' in INSTALLED_APPS as well. Folder structure : Django-Projects (root) project app static css home.css js manage.py Template : {% load staticfiles %} <link rel="stylesheet" href="{%

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

我与影子孤独终老i 提交于 2019-12-05 06:07: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 {% load staticfiles %} {% for img in img_to_display %} <a href="{{ img.img_wide.url}}" class="swipebox"

TemplateSyntaxError 'staticfiles' is not a valid tag library'

放肆的年华 提交于 2019-12-05 01:32:42
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" %}"> {% endblock %} <title>{% block title %}Tzibor{% endblock %}</title> </head> <body> <h1>It Works!</h1> {%