Questions tagged [django-staticfiles]

A Django app that provides helpers for serving static files.

django-staticfiles is a Django app that provides helpers for serving static files.

1241 questions
23
votes
4 answers

What is the correct way to load CSS staticfiles using npm and Django?

I want to load my static css files (e.g., Bootstrap) from my node_modules directory, like so: {% load staticfiles %} When I put .../node_modules/ in my…
YPCrumble
  • 26,610
  • 23
  • 107
  • 172
22
votes
2 answers

Django runserver not serving static files in development

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…
Meir
  • 1,943
  • 5
  • 22
  • 38
22
votes
2 answers

How to load a custom JS file in Django admin home?

I have a heavily customized Django admin where it's very simple to load a custom JS file for each of my ModelAdmins: class MyModelAdmin(admin.ModelAdmin): class Media: js = ('js/admin/mymodel.js',) But how do I do this for the admin…
Cloud Artisans
  • 4,016
  • 3
  • 30
  • 37
22
votes
2 answers

Where is template context processor in Django 1.5?

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…
user798719
  • 9,619
  • 25
  • 84
  • 123
21
votes
10 answers

Django staticfiles not found on Heroku (with whitenoise)

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…
vpoulain
  • 740
  • 1
  • 7
  • 18
20
votes
1 answer

Serving Media files during deployment in django 1.8

I am trying to deploy my django app on heroku. All the static files are served by whitenoise and are migrated successfully. But how do I get my media files that are uploaded using ImageField to display during production. my settings.py STATIC_URL =…
WutWut
  • 1,204
  • 2
  • 17
  • 31
19
votes
2 answers

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

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…
user5659156
19
votes
5 answers

Django static files on heroku

I deployed a django app to heroku, using "git push heroku master" which worked absolutely fine. I then created a second app on the same git using "heroku create second-app -r staging' and pushed using: git push staging master when I open second-app,…
Ammar Akhtar
  • 1,698
  • 3
  • 13
  • 25
17
votes
2 answers

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

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…
MarkerDave
  • 335
  • 1
  • 5
  • 13
17
votes
5 answers

how to point correctly to static image in django

I have a template that renders an image: {% load staticfiles %} 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,…
Atma
  • 29,141
  • 56
  • 198
  • 299
15
votes
2 answers

how to make static files works using django docker nginx and postgresql since its not serving them

When i try to access http://127.0.0.1:8000/admin, i get this. my folder structure is : django-react-nginx | |_ _ docker-compose.yml | > backend | |_ Dockerfile | |_ entrypoint.sh > languages | …
cu__007
  • 495
  • 1
  • 4
  • 14
15
votes
4 answers

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

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…
gkpo
  • 2,623
  • 2
  • 28
  • 47
15
votes
2 answers

Load static files for all templates in django

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.
Zags
  • 37,389
  • 14
  • 105
  • 140
14
votes
4 answers

No module named 'django.contrib.staticfiles.templatetags'

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 Django project from one PC to another. Watching for file changes with StatReloader Exception in thread…
TIshow
  • 918
  • 4
  • 12
  • 27
14
votes
3 answers

Django Whitenoise 500 server error in non debug mode

I am using django in my local machine. In order to serve the static files I used WhiteNoise along with it. When DEBUG = True all static files are correctly served. But when I changed DEBUG = False and set ALLOWED_HOSTS = ['*'] I'm getting 500 server…
1 2
3
82 83