Description

Admin inlines and forms do not support custom model fields that store non-unicode data in the database to be the primary key referenced by relation fields because they call force_unicode() on raw database data when rendering widgets and determining if data has changed.

A simple solution is to call the custom field's to_python method where this occurs because to_python supports the raw database data and will return an object that supports unicode transformation.

The patch I just uploaded adds support for ForeignKey and ManyToManyField relations.

The OneToOneField is not in this patch. I believe a design decision discussion would be required to implement OneToOneField support because it would have to pass its relation to the widget and currently does not do so.

I was mistaken about the OneToOne relation. I overlooked the RelatedFieldWidgetWrapper in django.contrib.admin.widgets. I now have this working for all relation fields. Inlines are also supported. I will submit a new patch soon. I am working on tests.

Admin inlines and forms do not support custom model fields that store non-unicode data in the database to be the primary key referenced by relation fields. →
Admin widgets and forms do not support custom model fields that store non-unicode data in the database to be the primary key referenced by relation fields.