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

id as UUID is causing errors #341

Open
wdifruscio opened this issue Feb 18, 2025 · 0 comments
Open

id as UUID is causing errors #341

wdifruscio opened this issue Feb 18, 2025 · 0 comments

Comments

@wdifruscio
Copy link

I do not use integer pks - its a very old project with uuid4s

I get a to_dict() error when defaulting to the id.

custom_objectID = 'field' would work, if I could just return str(instance.id) but I can't find a way to do this. Maybe I missed something.

For now, I am either going to have to create a custom_id property on each model..

My Error

  File "/usr/local/lib/python3.12/site-packages/algoliasearch/http/serializer.py", line 64, in body_serializer
    obj_dict = obj.to_dict()
               ^^^^^^^^^^^
AttributeError: 'UUID' object has no attribute 'to_dict'

Model

import uuid

class UUIDModel(models.Model):
    id = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4)

    class Meta:
        abstract = True
@wdifruscio wdifruscio changed the title id as UUID causing me a headache id as UUID is causing me errors Feb 18, 2025
@wdifruscio wdifruscio changed the title id as UUID is causing me errors id as UUID is causing errors Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant