Skip to content

Commit a66be68

Browse files
authored
fix inherited fks (#8)
1 parent 5412c62 commit a66be68

File tree

3 files changed

+366
-362
lines changed

3 files changed

+366
-362
lines changed

litestar_django/dto.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ def get_model_fields(
213213
# we need a concrete field to infer the type though, so we construct
214214
# it from the type of the related primary key field
215215
related_field = fk_tuple[1]
216+
# follow inherited fk relationships
217+
while isinstance(related_field, ForeignKey):
218+
related_field = related_field.related_fields[0][1]
219+
216220
id_field = type(related_field)(
217221
name=name,
218222
null=field.null,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "litestar-django"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
description = "Django model support for Litestar"
55
readme = "README.md"
66
license = { text = "MIT" }

0 commit comments

Comments
 (0)