Skip to content

Commit b5a18ae

Browse files
committed
feat: remove pk from Create/Update API schema
1 parent a04da32 commit b5a18ae

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

easy/controller/meta.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,15 @@ async def get_objs(self, request: HttpRequest, filters: str = None) -> Any: # t
109109
class DataSchema(ModelSchema):
110110
class Config:
111111
model = model_opts.model
112+
model_exclude = []
112113
if model_opts.model_exclude:
113-
model_exclude = model_opts.model_exclude
114+
model_exclude.extend(model_opts.model_exclude)
115+
# Remove pk(id) from Create/Update Schema
116+
model_exclude.extend([model._meta.pk.name])
114117
else:
115118
if model_opts.model_fields == MODEL_FIELDS_ATTR_DEFAULT:
116-
model_fields = MODEL_FIELDS_ATTR_DEFAULT
119+
# Remove pk(id) from Create/Update Schema
120+
model_exclude.extend([model._meta.pk.name])
117121
else:
118122
model_fields = (
119123
model_opts.model_fields # type: ignore

0 commit comments

Comments
 (0)