Django won't refresh staticfiles

django unchained
django unchained cast
django unchained 2
quentin tarantino
christoph waltz
django unchained oscar
christoph waltz awards
django unchained review

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 HTML but it bothers me that I can't do it the normal way anymore.

More details about this error (the #$&%# weirdest thing I've found):

The javascript is something like this:

old_sentence = "Dig that hole, forget the sun"  // this is what I want to change

new_sentence = "Run, rabbit, run"  // this is the new sentence, it just won't show up.

So, I changed the js and restart the server, still the html shows the old sentence. Then I deleted the reference to the login.js file and put all the js inside script tags in the HTML, of course, the new sentence appears. Then I include the login.js file, comment out the js inside the html BUT I delete all the content inside the login.js file, making it an empty file... but the old sentence still shows up. Therefore the old login.js file must be cashed somewhere I don't know. Then I open Chrome and try it all again, same problem.

What can it be? is there an option to force django to refresh staticfiles? I thought restarting the server was enough. .. should I reboot my computer? :/ lol.

List of accolades received by Django Unchained, Django Unchained is a 2012 American western film written and directed by Quentin Tarantino. Outstanding Ensemble, Django Unchained – Victoria Thomas, Won. Outstanding Motion Picture, Django Unchained, Nominated. Outstanding  Django Unchained (/ ˈ dʒ æ ŋ ɡ oʊ /) is a 2012 American revisionist Western film written and directed by Quentin Tarantino, starring Jamie Foxx, Christoph Waltz, Leonardo DiCaprio, Kerry Washington, and Samuel L. Jackson, with Walton Goggins, Dennis Christopher, James Remar, Michael Parks, and Don Johnson in supporting roles.

It sounds like both your browsers have the javascript file cached. In Chrome you can clear the cache by pressing Ctrl + Shift + Del and ticking just 'Cached images and files'. Firefox probably has a similar shortcut.

You can take a look at this question on tips to disable caching of static files on your development server altogether.

Django Unchained, Django Unchained. Golden Globes: 5 Nominations, 2 Wins. With the help of a German bounty hunter, a freed slave sets out to rescue his wife from a brutal  As of December 7, 2013, Django Unchained has earned over $425 million at the box office. The film has garnered various awards and nominations, with most nominations recognising the film itself, Tarantino's screenplay and the cast's acting performances, particularly those of Christoph Waltz and Leonardo DiCaprio.

You need to bust the browser cache. This template tag will output a time based uuid when DEBUG=True. Otherwise it will look for a PROJECT_VERSION environment variable. If that is not found it will output a static version number.

import os
import uuid
from django import template                                                                                                              
from django.conf import settings                                                                                                         

register = template.Library()                                                                                                            

def cache_bust():                                                                                                                        

    if settings.DEBUG:                                                                                                                   
        version = uuid.uuid1()                                                                                                           
        version = os.environ.get('PROJECT_VERSION')                                                                                       
        if version is None:                                                                                                              
            version = '1'                                                                                                                

    return '__v__={version}'.format(version=version)

You would use in a template like this:

{% load cache_bust %}

<link rel="stylesheet" href="{% static "css/project.css" %}?{% cache_bust %}"/>

and here is the resulting output:

<link rel="stylesheet" href="/static/css/project.css?__v__=7d88de4e-7258-11e7-95a7-0242ac130005"/>

Christoph Waltz winning Best Supporting Actor for "Django , Christoph Waltz wins best supporting actor Oscar for Django Unchained. This article is more than 7 years old. Christoph Waltz has scooped the  Learn to build REST API in Django with Django REST framework tutorial. 4. Railway Enquiry System. Project idea – The Indian railway system has provided us with an API from through which we can gather all the information about the status of the train, PNR number, etc in real-time. The idea of this project is to create a web app

I have also struggled with this problem for hours. I have tried to inject random string using Javascript, but this method seems stupid and ugly-looking. One possible way to handle this problem is to introduce a custom tag. See this document for details:

Specifically, you need to create a package called templatetags in whatever apps you have created (or create a new one if you want). And you create any file in this package, and write something like this:

from django import template
from django.utils.crypto import get_random_string
from django.templatetags import static

register = template.Library()

class StaticExtraNode(static.StaticNode):

    def render(self, context):
        return super().render(context) + '?v=' + get_random_string(32)

def do_static_extra(parser, token):
    return StaticExtraNode.handle_token(parser, token)

def static_extra(path):
    return StaticExtraNode.handle_simple(path)

then you can use tag {% static_no_cache '.../.../path...' %} to create a path with random arguments!

I hope this would help!

Quentin Tarantino Wins Original Screenplay: 2013 Oscars, Quentin Tarantino wins best original screenplay Oscar for Django Unchained. This article is more than 7 years old. Director takes best writing  I am still new to django and I am having problem with my CSS working. I have followed the direction from the link: Django Static Link tutorial, on handling static files. But it is still not working

Django Unchained, Both of the Oscars wins for “Django Unchained” — Christoph Waltz (Best Supporting Actor) and Quentin Tarantino (Best Original Screenplay)  Django Lessons are weekly screencasts about Django Web Framework and related topics like python, javascript, linux servers, deployment. The videos are short and to the point. The topics target the intermediate Django developer interested in Cloud/Web technologies.

Christoph Waltz wins best supporting actor Oscar for Django , But after his box office/Oscar breakout Pulp Fiction ($214 million, seven Oscar noms, with an Original Screenplay win for Tarantino and Roger  EmptyResultSet may be raised during query generation if a query won’t return any results. Most Django projects won’t encounter this exception, but it might be useful for implementing custom lookups and expressions.

Quentin Tarantino wins best original screenplay Oscar for Django , Django won’t check the backends that follow. Note Once a user has authenticated, Django stores which backend was used to authenticate the user in the user’s session, and re-uses the same backend for the duration of that session whenever access to the currently authenticated user is needed.

Christoph Waltz and Quentin Tarantino make Oscars history with , Assuming this is the main of your Django project, the URL /redirect/ now redirects to /redirect-success/.. To avoid hard-coding the URL, you can call redirect() with the name of a view or URL pattern or a model to avoid hard-coding the redirect URL.

  • have you tried running python collectstatic? It sounds like you are modifying your working copy of the javascript and it is referencing the collected/out-of-date file.
  • Did you try Ctrl-F5 to refresh page with cache clearing ?
  • Thanks for your comments and your time. I already found the error, it was indeed a weird one. I found that django is pointing local environment staticfiles to the AWS Bucket that I use on deployment. So... running collectstatic is part of the solution I guess, the rest is re-configuring my staticfiles settings and somehow solving the AWS Bucket problem.
  • If you are using uwsgi with django, you may need to restart uwsgi to avoid getting old content being served
  • I am not sure if this is still relevant, but it can be that in dev environment if you have staticfiles_dirs set, and not only the static root, then django serves the static files from the _dirs not from the _root. That is what happens with me. If I work on the static file in the root, no change applied till collectstatic is run. If I work on a static file in the _dir, Ctrl+F5 applies the change.
  • The first option won't work on the development environment. That last point is a good tip though, I was changing the actual file name until now, but that's much better :)
  • How would you add the random parameter to <script src="{% static 'js/login.js' %} "></script>?
  • Why would you want to clear all static files? Doesn't that mean you would have to reupload them?
  • This ruined my server! It deleted my entire git repository. Why is this the selected answer?
  • I tried your first method and it deleted all my static files -.-
  • No way , as a good programmer you don't want clients to refresh in this way :(
  • He's on a dev server using runserver. Static files are directly loaded from their original location, so collectstatic won't change anything.
  • Please add some explanation to your answer such that others can learn from it - what makes you think that this works better than other approaches that received dozens of upvotes?
  • Instead of stopping the server and do some extra stuff. i.e run commands or add some code to the project. just refresh your page via cmd+shift+r. (Hard refresh) A hard refresh is a way of clearing the browser’s cache for a specific page, to force it to load the most recent version of a page.
  • Please add all information to your answer by editing it