Skip to content
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

Avoid SQL update on blog post view #1963

Open
leoholz opened this issue Aug 5, 2020 · 2 comments
Open

Avoid SQL update on blog post view #1963

leoholz opened this issue Aug 5, 2020 · 2 comments

Comments

@leoholz
Copy link

leoholz commented Aug 5, 2020

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?

@leoholz leoholz changed the title Avoiding SQL update on blog post view Avoid SQL update on blog post view Aug 5, 2020
@leoholz
Copy link
Author

leoholz commented Aug 6, 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.

@jerivas jerivas self-assigned this Aug 11, 2020
@jerivas jerivas closed this as completed Jul 29, 2021
@jerivas jerivas reopened this Jul 29, 2021
@jerivas jerivas removed their assignment Sep 27, 2022
@GOUTHAM-2002
Copy link

Can i work on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants