django-static

How to run static file when debug is false? [closed]

感情迁移 提交于 2021-02-13 17:41:16
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 days ago . Improve this question With debug turned off Django won't handle static files for you any more - your production web server. Implement this code inside your project: settings.py STATIC_DIR=os.path.join(BASE_DIR,'static') STATIC_URL = '/static/' if DEBUG: STATICFILES_DIRS = [ STATIC_DIR,

How to run static file when debug is false? [closed]

有些话、适合烂在心里 提交于 2021-02-13 17:39:27
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 days ago . Improve this question With debug turned off Django won't handle static files for you any more - your production web server. Implement this code inside your project: settings.py STATIC_DIR=os.path.join(BASE_DIR,'static') STATIC_URL = '/static/' if DEBUG: STATICFILES_DIRS = [ STATIC_DIR,

Static files doesn't load anymore - Django

独自空忆成欢 提交于 2021-01-29 13:37:11
问题 In the beginning everything worked perfectly fine, but now I have a problem where my static files doesn't load. I think this is a very weird problem since I didn't really touch anything that could've had an influence on the problem when it happened. Everything else is working fine, I just can't get the static files for some reason. I sometimes get a 200 http response trying to get the static files like so: [20/Aug/2020 16:12:51] "GET /order/checkout/ HTTP/1.1" 200 2029 [20/Aug/2020 16:12:51]

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

Invalid block tag: 'static'

余生颓废 提交于 2020-01-01 03:55:05
问题 Server returned TemplateSyntaxError at / Invalid block tag: 'static' on this line: <img src="{% static 'icon/logo.png' %}"> . The whold html file is like this (it's an html file {% include %}ed by another one): {% load staticfiles %} <div class="header"> <nav> <ul class="nav nav-pills pull-right"> <li role="presentation"><a href="{% url 'offer rank' %}">潮品榜</a></li> <li role="presentation"><a href="{% url 'user rank' %}">达人榜</a></li> <li role="presentation"><a href="#" data-toggle="modal"

apache server cant find static files in Django project

做~自己de王妃 提交于 2019-12-23 15:54:17
问题 I'm trying to upload my code on an apache server using mod_python. I have tried a lot but the server is not able to access my static files (all my images, js and css). Here are my Virtualhost settings: <VirtualHost *:80> ServerName mysite.com ServerAlias www.mysite.com Alias /static/ /home/mysite/products/static/ # RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.mysite\.com RewriteRule (.*) http://mysite.com$1 [R=301,L] # DocumentRoot /home <Directory /home/mysite/> SetHandler mod_python

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

孤人 提交于 2019-12-06 07:57:37
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 I use a simple Django app for making Python / Django settings available in javascript. https://github.com/incuna/django-settingsjs

Invalid block tag: 'static'

南笙酒味 提交于 2019-12-03 23:51:09
Server returned TemplateSyntaxError at / Invalid block tag: 'static' on this line: <img src="{% static 'icon/logo.png' %}"> . The whold html file is like this (it's an html file {% include %}ed by another one): {% load staticfiles %} <div class="header"> <nav> <ul class="nav nav-pills pull-right"> <li role="presentation"><a href="{% url 'offer rank' %}">潮品榜</a></li> <li role="presentation"><a href="{% url 'user rank' %}">达人榜</a></li> <li role="presentation"><a href="#" data-toggle="modal" data-target="#start">登陆</a></li> <li role="presentation"><a href="#" data-toggle="modal" data-target="

How to properly extend and include in Django tempates

最后都变了- 提交于 2019-11-30 09:58:30
问题 Following is my homepage.html is home app {% extends "base.html" %} {% load static %} <link rel = "stylesheet" href = "{% static 'css/home.css' %}" > #reference to stylesheet in the home app static directory {% block body %} <h1>I am homepage</h1> {% endblock %} My base.html in the project root folder is the following <!DOCTYPE html> <html> <head> <link rel = "stylesheet" href = "{% static 'base.css' %}" > #stylesheet in root folder </head> <body> {% block content %} {% endblock %} </body> <

Django static files won't load

感情迁移 提交于 2019-11-30 06:46:49
问题 i'm a Django newbie working on my first project and having a problem with static files. I have created a simple auth system using django.contrib.auth consisting of two templates: mysite/templates/index.html and mysite/templates/registration/login.html . I have global static content in mysite/static which I want to be able to access on all templates rendered by all apps. mysite/templates/index.html contains <img src="{{ STATIC_URL }}pics03.jpg"/> which renders as "static/pics03.jpg" and loads