@@ -122,6 +122,7 @@ if __name__ == '__main__':
122122- Method 1: Create model through ` SQLModel ` .
123123
124124``` python
125+ from typing import Optional
125126from sqlmodel import SQLModel
126127from fastapi_amis_admin.models.fields import Field
127128
@@ -132,7 +133,7 @@ class Base(SQLModel):
132133
133134# Create an SQLModel, see document for details: https://sqlmodel.tiangolo.com/
134135class Category (SQLModel , table = True ):
135- id : int = Field(default = None , primary_key = True , nullable = False )
136+ id : Optional[ int ] = Field(default = None , primary_key = True , nullable = False )
136137 name: str = Field(title = ' CategoryName' , max_length = 100 , unique = True , index = True , nullable = False )
137138 description: str = Field(default = ' ' , title = ' Description' , max_length = 255 )
138139
@@ -188,7 +189,7 @@ from pydantic import BaseModel, Field
188189
189190
190191class CategorySchema (BaseModel ):
191- id : int = Field(default = None , primary_key = True , nullable = False )
192+ id : Optional[ int ] = Field(default = None , primary_key = True , nullable = False )
192193 name: str = Field(title = " CategoryName" )
193194 description: str = Field(default = " " , title = " CategoryDescription" )
194195
@@ -200,7 +201,6 @@ class CategorySchema(BaseModel):
200201
201202``` python
202203from fastapi import FastAPI
203- from sqlmodel import SQLModel
204204from fastapi_amis_admin.admin.settings import Settings
205205from fastapi_amis_admin.admin.site import AdminSite
206206from fastapi_amis_admin.admin import admin
0 commit comments