You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there! During rendering of a blog post page Mezzanine writes back the whole blog post to the database: UPDATE "blog_blogpost" SET ... Actually I cannot see changes in the blog post content.
For my current setup it would be very helpful to load the page without generating a write. Is there a way to do this? Or can someone explain why it happens so I can modify the source if necessary?
The text was updated successfully, but these errors were encountered:
leoholz
changed the title
Avoiding SQL update on blog post view
Avoid SQL update on blog post view
Aug 5, 2020
Ok, I found the problem. The write is caused by the automatic short URL creation in core/models.py:
def set_short_url(self):
if not self.short_url or self.short_url == SHORT_URL_UNSET:
self.short_url = self.generate_short_url()
self.save()
if self.short_url == SHORT_URL_UNSET:
self.short_url = self.get_absolute_url_with_host()
In the case that self.generate_short_url() returns SHORT_URL_UNSET, self.save() is called at every request. It would be great to call self.save() only when short_url has an updated value.
Hi there! During rendering of a blog post page Mezzanine writes back the whole blog post to the database: UPDATE "blog_blogpost" SET ... Actually I cannot see changes in the blog post content.
For my current setup it would be very helpful to load the page without generating a write. Is there a way to do this? Or can someone explain why it happens so I can modify the source if necessary?
The text was updated successfully, but these errors were encountered: