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.

Hi, I tried using uuids as ids and it doesn’t work because of the save method in TenantMixin. When saving the setattr(self, self.tenant_field, tenant_value) line never gets called because self.pk has value when dealing with uuids different from IntegerField. I created my own abstract class and added a created field it did the trick, but it would be nice to have native support for uuids.

def save(self, *args, **kwargs):
    tenant_value = get_current_tenant_value()
    if not self.pk and tenant_value and not isinstance(tenant_value, list):
        setattr(self, self.tenant_field, tenant_value)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
louiseGrandjonccommented, May 25, 2020

Hi,

I just released a new version 2.2.1 with the fix for this.

1reaction
s4kecommented, Jan 5, 2020

We fixed it by using this implementation in our model base class:

    def save(self, *args, **kwargs):
        tenant_value = get_current_tenant_value()
        if self._state.adding and tenant_value and not isinstance(tenant_value, list):
            setattr(self, self.tenant_field, tenant_value)

        return super().save(*args, **kwargs)
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a UUID, and why should you care? - Cockroach Labs
A UUID – that's short for Universally Unique IDentifier, by the way – is a 36-character alphanumeric string that can be used to...
Read more >
Universally unique identifier - Wikipedia
A universally unique identifier (UUID) is a 128-bit label used for information in computer systems. The term globally unique identifier (GUID) is also...
Read more >
Mysql 8.0: UUID support
In MySQL 8.0.0 we introduced many new features; among those, three new functions that ease and enhance the support for working with UUIDs....
Read more >
UUID Data Type - MariaDB Knowledge Base
The UUID data type is intended for the storage of 128-bit UUID (Universally Unique Identifier) data. See the UUID function page for more...
Read more >
Documentation: 15: 8.12. UUID Type - PostgreSQL
The data type uuid stores Universally Unique Identifiers (UUID) as defined by RFC 4122, ISO/IEC 9834-8:2005, and related standards.
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