django-staticfiles

Heroku & Django: “OSError: No such file or directory: '/app/{myappname}/static'”

…衆ロ難τιáo~ 提交于 2019-11-30 00:00:46
I have a Django app on Heroku. I am having some problems with static files (they are loading in one Heroku environment but not another), so I tried the debug command recommended here . $ heroku run python manage.py collectstatic --noinput Running `python manage.py collectstatic --noinput` attached to terminal... up, run.8771 OSError: [Errno 2] No such file or directory: '/app/{myappname}/static' Here is my settings.py, which is the same thing Heroku recommends: import os import os.path BASE_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = 'staticfiles' STATIC_URL = '/static/'

django dev server, adding headers to static files

依然范特西╮ 提交于 2019-11-29 18:32:00
问题 Using the django dev server (1.7.4), I want to add some headers to all the static files it serves. It looks like I can pass a custom view to django.conf.urls.static.static , like so: if settings.DEBUG: from django.conf.urls.static import static from common.views.static import serve urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT, view=serve) And common.views.static.serve looks like this:

Django STATIC_URL is not working

久未见 提交于 2019-11-29 01:32:28
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="{{ STATIC_URL }}css/main.css" ...> but, in my broswer is: <link href="css/main.css" ...> (Just render

Django serve static index.html with view at '/' url

雨燕双飞 提交于 2019-11-29 01:27:53
问题 I have my index.html in /static/ folder. My django app is running ok when i try: http://127.0.0.1:8000/index.html But i want to acces index.html by url: http://127.0.0.1:8000/ I wrote a view and it works: class IndexView(TemplateView): template_name = 'index.html' I also added to urls.py(this lets me serve static like http://127.0.0.1:8000/css/style.css ): url(r'^(?P<path>.*)$', 'django.contrib.staticfiles.views.serve', { 'document_root': settings.STATIC_ROOT, 'show_indexes':True }), But i

how to point correctly to static image in django

安稳与你 提交于 2019-11-28 22:24:10
问题 I have a template that renders an image: {% load staticfiles %} <img src="{% static "img/logo.png" %}" alt="My image"/> The image link is broken, but it points to: localhost/static/img/logo.png What are values I need to set for static_root, static_url, and STATICFILES_DIRS to get this image to show up correctly? This is my directory structure: myprojectname (top level) --- myprojectname --- --- myproectname --- --- --- settings --- --- --- --- base.py (setting.py) --- --- static --- --- ---

Heroku & Django: “OSError: No such file or directory: '/app/{myappname}/static'”

ぃ、小莉子 提交于 2019-11-28 21:00:47
问题 I have a Django app on Heroku. I am having some problems with static files (they are loading in one Heroku environment but not another), so I tried the debug command recommended here. $ heroku run python manage.py collectstatic --noinput Running `python manage.py collectstatic --noinput` attached to terminal... up, run.8771 OSError: [Errno 2] No such file or directory: '/app/{myappname}/static' Here is my settings.py, which is the same thing Heroku recommends: import os import os.path BASE

Django won't refresh staticfiles

假装没事ソ 提交于 2019-11-28 18:11:01
This is annoying. I have a javascript file referenced on a django template: <script src="{% static 'js/login.js' %} "></script> I made some changes to that js file. Then, I refresh the page and I can't see the changes happen. If I remove the javascript from the file and put it in the HTML, it works correctly, but if I try to do it using the external js file then it doesn't. I have tried closing the server and running runserver several times, I've also tried changing from Firefox to Chrome. It makes no sense at all. Please help me understand, I can get away with including all the js inside the

Django and service workers - serve “sw.js” at application's root url

北城以北 提交于 2019-11-28 10:11:23
So I'm building a Django progressive web app with offline support using service workers. According to google's documentation , the sw.js file should be at the root of the app's url: You need to do this because the scope of a service worker (the set of urls that the ServiceWorker will load for) is defined by the directory where it resides. At the moment, I'm serving all static assets from http://example.com/static/ folder. But I need to serve this specific file at a url like: http://example.com/sw.js . Any idea how I can achieve this? I could make a specific nginx rule to do this redirection,

Django runserver not serving static files in development

断了今生、忘了曾经 提交于 2019-11-28 09:07:12
I am using Django with runserver for my development. When I deploy to my production server I can see all my static files, but not on my local computer. I did collectstatic and I have set DEBUG = True . I found many different opinions online, the most prominent being the STATICFILES_DIRS , but that does not work for me. How can I set it so that in my development environment I can see the static files, and when I upload my files to the server I do not need to make any changes for the production environment to work properly. Edit - my urls.py file: from django.conf.urls import patterns, include,

Where is template context processor in Django 1.5?

烈酒焚心 提交于 2019-11-28 08:11:52
Is it supposed to be listed in Settings.py automatically or do I have to add it? I am having a ridiculously hard time serving up an image file in development and the docs are too terse for my taste and don't spell things out clearly to me for some reason. I'd like to check to see what my template_context_processors are, but where is it located? It's not in my settings.py file. Do I need to edit this typically? ("django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core