Skip to content

Commit ed01b3f

Browse files
committed
Fix
1 parent 5170709 commit ed01b3f

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

docs/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ <h1>FastAdmin | Documentation</h1>
404404
</li>
405405
<li>
406406
<strong>Updated:</strong>
407-
13 April 2026
407+
14 April 2026
408408
</li>
409409
</ul>
410410
</div>
@@ -3378,7 +3378,7 @@ <h3>Methods and Attributes</h3>
33783378
return sort_by
33793379

33803380
async def serialize_obj_attributes(
3381-
self, obj: Any, attributes_to_serizalize: list[ModelFieldWidgetSchema]
3381+
self, obj: Any, attributes_to_serizalize: list[ModelFieldWidgetSchema], list_view: bool = False
33823382
) -> dict[str, Any]:
33833383
"""Serialize orm model obj attribute to dict.
33843384

@@ -3395,7 +3395,7 @@ <h3>Methods and Attributes</h3>
33953395
value = format(value, "f")
33963396

33973397
serialized_dict[field.name] = value
3398-
if field.form_widget_type in (WidgetType.UploadFile, WidgetType.UploadImage) and value:
3398+
if not list_view and field.form_widget_type in (WidgetType.UploadFile, WidgetType.UploadImage) and value:
33993399
serialized_dict[f"{field.name}__url"] = await self.get_file_url(field.name, value, obj)
34003400
if inspect.iscoroutinefunction(obj.__str__):
34013401
str_fn = obj.__str__
@@ -3443,7 +3443,7 @@ <h3>Methods and Attributes</h3>
34433443
else:
34443444
attributes_to_serizalize.append(field)
34453445

3446-
obj_dict.update(await self.serialize_obj_attributes(obj, attributes_to_serizalize))
3446+
obj_dict.update(await self.serialize_obj_attributes(obj, attributes_to_serizalize, list_view=list_view))
34473447

34483448
for field_name in fields_for_serialize:
34493449
display_field_function = getattr(self, field_name, None)

fastadmin/api/service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ async def upload_file(
341341

342342
try:
343343
obj = await admin_model.orm_get_obj(id) if id is not None else None
344+
if id is not None and obj is None:
345+
raise AdminApiException(404, detail=f"{model} with id {id} not found.")
344346

345347
if inspect.iscoroutinefunction(admin_model.upload_file):
346348
upload_file_fn = admin_model.upload_file

fastadmin/models/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def resolve_sort_by(self, sort_by: str) -> str:
375375
return sort_by
376376

377377
async def serialize_obj_attributes(
378-
self, obj: Any, attributes_to_serizalize: list[ModelFieldWidgetSchema]
378+
self, obj: Any, attributes_to_serizalize: list[ModelFieldWidgetSchema], list_view: bool = False
379379
) -> dict[str, Any]:
380380
"""Serialize orm model obj attribute to dict.
381381
@@ -392,7 +392,7 @@ async def serialize_obj_attributes(
392392
value = format(value, "f")
393393

394394
serialized_dict[field.name] = value
395-
if field.form_widget_type in (WidgetType.UploadFile, WidgetType.UploadImage) and value:
395+
if not list_view and field.form_widget_type in (WidgetType.UploadFile, WidgetType.UploadImage) and value:
396396
serialized_dict[f"{field.name}__url"] = await self.get_file_url(field.name, value, obj)
397397
if inspect.iscoroutinefunction(obj.__str__):
398398
str_fn = obj.__str__
@@ -440,7 +440,7 @@ async def serialize_obj(self, obj: Any, list_view: bool = False) -> dict:
440440
else:
441441
attributes_to_serizalize.append(field)
442442

443-
obj_dict.update(await self.serialize_obj_attributes(obj, attributes_to_serizalize))
443+
obj_dict.update(await self.serialize_obj_attributes(obj, attributes_to_serizalize, list_view=list_view))
444444

445445
for field_name in fields_for_serialize:
446446
display_field_function = getattr(self, field_name, None)

fastadmin/static/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)