Problem
POST /beam-beam-cover-plate-welded/design/ was returning:
expected str, bytes or os.PathLike object, not NoneType
The error was caused by this line in web_pattern():
files("osdag_core.data.ResourceFiles.images").joinpath("Uw.png")
importlib.resources.files() failed to resolve the image path correctly in the Django environment, resulting in an invalid/None path and crashing the API.
Fix
Replaced it with a direct Django filesystem path using settings.BASE_DIR:
image_path = os.path.join(
settings.BASE_DIR,
"osdag_core",
"data",
"ResourceFiles",
"images",
"Uw.png"
)
Result
Design API works correctly and the image loads without errors.