question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django 2.1 support

See original GitHub issue

[Spawning off #18]

There seems to be an odd bug in django-mptt (or in the way Hordak is using django-mptt) that is preventing the account tree updating correctly in Django >= 2.1. I’ve therefore only marked Django < 2.1 as supported.

Travis is is testing on Django 2.1, but with failures allowed. The problematic test is hordak.tests.models.test_core.AccountTestCase.test_full_code_changes_on_update. It seems that the accounts tree is not having it’s left/right values set correctly, and therefore the PG trigger which recalculates the Account’s full_code makes a mistake.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
p-baumcommented, Oct 25, 2018

I think I got it. Tests passing.

Whenever a new account is inserted, mptt adjusts the lft and rght values of (possibly many) other accounts as part of its duty to maintain a valid tree. This mass database update leaves the affected in memory account objects with outdated and invalid tree information. Should any of these objects be used to save new data, the invalid tree data is inadvertently saved along with it thus corrupting the tree. Maths is not my strong point so I would err on the side of caution and assume that whenever a new account is inserted, all in memory objects hold invalid data. Seeing as we don’t actually need this tree data, I think it would be optimal to never load it in the first place but I haven’t found a way to avoid this. What I have found is a way to prevent the saving of it. The save() method accepts a keyword argument ‘update_fields’ which allows you to provide a list of fields to update while ignoring the others:

    def save(self, *args, **kwargs):
        is_creating = not bool(self.pk)
        if is_creating:
            update_fields = None
        else:
            update_fields = [
                'uuid', 'name', 'parent', 'code', 'type',
                'is_bank_account', 'currencies'
            ]
        super(Account, self).save(*args, update_fields=update_fields, **kwargs)

What I do not understand is how it worked up until django<2.1 - but thats of little concern now.

Hope it checks out with you and hope to see a django 2.1.2 compatible release sometime soon.

0reactions
adamcharnockcommented, Jul 23, 2019

Closed by #42. Released in 1.9.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django 2.1 release notes
Django 2.1 supports Python 3.5, 3.6, and 3.7. Django 2.0 is the last version to support Python 3.4. We highly recommend and only...
Read more >
Django - endoflife.date
Check End of Life, Support Schedule, and release timelines for AlmaLinux OS, Alpine Linux, Amazon Linux, Android OS, Angular, Ansible-core, Ansible, antiX, ...
Read more >
Django - PyPI
Supporting the Development of Django. Django's development depends on your contributions. If you depend on Django, remember to support the Django Software ...
Read more >
Django 2.1 support · Issue #220 - GitHub
I have this working with Django 2.1. Make sure you have 100% followed these instructions for setting up your celery beat worker.
Read more >
How to upgrade Django to a newer version
For each feature release, use the latest patch release (e.g. for 2.1, use 2.1.15). ... some of your dependencies may not yet support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found