Opened 9 years ago

Closed 8 years ago

#17070 closed Bug (wontfix)

newly created templatetags module not loaded or recognized until server restart

Reported by: UltraAyla Owned by: nobody
Component: Template system Version: 1.3
Severity: Normal Keywords: templatetag tags
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When a new templatetags module is added to an installed app, django will throw an error upon encountering the "load" tag and specify that it can't find it until the server is restarted. Upon restarting the server, the templatetags module is recognized. I'm new to django so I'm not sure if this is something that should be fixed or if it just needs to be specified in the documentation on creating template tags.

Change History (4)

comment:1 Changed 9 years ago by Preston Holmes

Resolution: invalid
Status: newclosed

This is a general feature of a running server. There are lots of areas in Django that are loaded when the first starts and are not reloaded during run. The development server will auto-reload many things, and this is mentioned in the tutorial, but otherwise you need to restart a server process. Because there are many methods of deploying Django - this becomes a deployment question, and difficult to document for all deployment options. See for example docs on uWSGI for gradually restarting worker processes for example.

comment:2 Changed 9 years ago by Carl Meyer

Resolution: invalid
Status: closedreopened
Triage Stage: UnreviewedAccepted

I don't think this is really a bug related to deployment servers; in those cases you pretty much need to reload the server for all code changes.

But I do think there is a valid bug here, and it's specifically related to cases where Django auto-discovers certain modules at startup and then caches what it discovers (templatetags and the admin). This has a bad interaction specifically with the runserver auto-reloader. In general the auto-reloader will reload the server automatically whenever code changes. If you add a new module and then import it in your code, that involves changing existing code, so the auto-reloader reloads. But if you add a new templatetag module and try to load and use it in a template, Django will never find it until you manually restart runserver. This is genuinely surprising behavior when you hit it.

I'm not sure at this point what the fix would look like, or if there is even a good fix. We may in the end need to just wontfix this for lack of a good solution. But I think it should be left open at this point to see if anyone has good ideas for a fix, as it is a real issue.

comment:3 Changed 9 years ago by Preston Holmes

related: #12772

comment:4 Changed 8 years ago by Aymeric Augustin

Resolution: wontfix
Status: reopenedclosed

This looks really hard to fix. Django would have to watch all locations where it attempted to auto-discover things for changes.

The bug is valid but I don't think it can be fixed with the current autoreloader.

Note: See TracTickets for help on using tickets.
Back to Top