Closed mumumumu closed 5 years ago
This is when I try to simply render a composite field in the Django admin.
@admin.register(Organization)
class OrganizationAdmin(ModelAdmin):
fields = (
'name',
'address',
)
My model & composite type are defined as:
class CompositeAddress(CompositeType):
address1 = models.CharField(blank=True, max_length=200)
address2 = models.CharField(blank=True, max_length=200)
city = models.CharField(blank=True, max_length=200)
state = USStateField(blank=True)
zip_code = USZipCodeField(blank=True)
class Meta:
db_type = 'composite_address'
class Organization(Model):
name = models.CharField(max_length=200)
address = CompositeAddress.Field(blank=True, null=True)
Interesting, I don't think I've ever tried using this with the admin actually. Thanks.
I've run into this error when trying to render null composite fields in the admin:
I've added a simple fix to return an empty dict when the value of the field is null in the
CompositeTypeField
to prevent the widget from breaking.