mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2025-08-26 10:40:18 +08:00
Load ForeignKey models inside Model.resolve_data
This commit is contained in:
@ -159,6 +159,11 @@ class Model(Resource):
|
||||
if input_.context.get("disabled") or isinstance(input_, inputs.DisplayOnly):
|
||||
continue
|
||||
name = input_.context.get("name")
|
||||
if isinstance(input_, inputs.ForeignKey):
|
||||
v = data.getlist(name)[0]
|
||||
model = await input_.model.get(id=v)
|
||||
ret[name] = model
|
||||
continue
|
||||
if isinstance(input_, inputs.ManyToMany):
|
||||
v = data.getlist(name)
|
||||
value = await input_.parse_value(request, v)
|
||||
|
Reference in New Issue
Block a user