Models with custom PKs not called id
throw errors on schema generation.
#25
Labels
bug
Something isn't working
id
throw errors on schema generation.
#25
When grabbing a models "ID", should probably be using
model.pk
- https://docs.djangoproject.com/en/dev/ref/models/instances/#the-pk-property.A models
id
field is accessable through.pk
, as the models PK is always accessible there. When dealing with custom PKs, this causes drf-spectacular to fall over aAttributeError: type object 'MethodCall' has no attribute 'id'
error.For example, I have a model as follows:
As the
transaction
field hasprimary_key=True
, Django doesn't generate a.id
field. Howevertransaction
is still accessable via.pk
.This is where it's an issue for me:
drf-spectacular/drf_spectacular/openapi.py
Line 359 in bca26d3
It may also be an issue here:
drf-spectacular/drf_spectacular/openapi.py
Line 399 in bca26d3
The text was updated successfully, but these errors were encountered: