iommirocks / iommi

Your first pick for a django power cord
http://iommi.rocks
BSD 3-Clause "New" or "Revised" License
688 stars 47 forks source link

Bug: Select Field does not work if pk is of type uuid #469

Closed astrocbxy closed 11 months ago

astrocbxy commented 11 months ago

Steps to reproduce:

minimal failing example

import uuid

from django.urls import path
from django.db import models

from iommi import Form

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

class TestModel2(models.Model):
    model = models.ForeignKey(TestModel, on_delete=models.CASCADE)

urlpatterns = [path("test/", Form.create(auto__model=TestModel2).as_view())]

if you try to use the select field you get:

TypeError: Object of type UUID is not JSON serializable