-
-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching behavior - possibly incorrect #43
Comments
No, it should not update the cache if your ForeignKey is changed. To quote the docs: "dbtemplates uses Django’s default caching infrastructure for caching, and operates automatically when creating, updating or deleting templates in the database". That applies to changing the templates, but not to setting relations to a template. As to what you're trying to accomplish, I'm out of ideas. If you're simply changing the relation to a template, and use the template's |
Good point about caching and ForeignKey relations. Maybe the issue is not related to caching? As you describe, I am returning the template's '' field in '<get_template_names>'. (I also have a default template as a fallback because the template field is not required). So here's the sequence I just went though.
Debug Template-loader postmortem says:
|
Further info: Forgetting about the part with changing foreignkeys on my models... If I leave the foreign key alone, and have no cache settings in my settings.py, I will get TemplateDoesNotExist when I try to load a page with that template. Then I go to the admin, "Repopulate cache with selected template", and the page loads ok. Wait a few minutes, and then try to load page again. I get TemplateDoesNotExist again. So without cache settings created in settings.py, I'm not sure where the "Repopulate cache with selected template" is loading the template to. But it seems that the Loader is not correctly falling back to getting the template from the database if it fails to find it in the cache. Hope that helps pinpoint the issue. |
I am using a foreignkey to dbtemplates Template model to determine how to display another model. ie.
When I switch the template field on MyModel to another template via the admin, MyModel is not getting the correct template for display. I get "TemplateDoesNotExist" sometimes. Other times it continues to display using the previous template. It never updates to the new template though. I have to use the admin action "repopulate cache with selected items" to get it to find the template again.
I am using a class based view and defining "get_template_names()" to get the Template model from the foreignkey.
Shouldn't the template be updating when the foreignkey is changed? And shouldn't it find the correct one either in the cache or via the database?
(Django 1.5)
The text was updated successfully, but these errors were encountered: