Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
amisadmin committed Dec 20, 2023
1 parent bc04491 commit 2fffa00
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ if __name__ == '__main__':
- Method 1: Create model through `SQLModel`.

```python
from typing import Optional
from sqlmodel import SQLModel
from fastapi_amis_admin.models.fields import Field

Expand All @@ -132,7 +133,7 @@ class Base(SQLModel):

# Create an SQLModel, see document for details: https://sqlmodel.tiangolo.com/
class Category(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title='CategoryName', max_length=100, unique=True, index=True, nullable=False)
description: str = Field(default='', title='Description', max_length=255)

Expand Down Expand Up @@ -188,7 +189,7 @@ from pydantic import BaseModel, Field


class CategorySchema(BaseModel):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title="CategoryName")
description: str = Field(default="", title="CategoryDescription")

Expand All @@ -200,7 +201,6 @@ class CategorySchema(BaseModel):

```python
from fastapi import FastAPI
from sqlmodel import SQLModel
from fastapi_amis_admin.admin.settings import Settings
from fastapi_amis_admin.admin.site import AdminSite
from fastapi_amis_admin.admin import admin
Expand Down
5 changes: 2 additions & 3 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Base(SQLModel):

# 创建SQLModel模型,详细请参考: https://sqlmodel.tiangolo.com/
class Category(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title='CategoryName', max_length=100, unique=True, index=True, nullable=False)
description: str = Field(default='', title='Description', max_length=255)

Expand Down Expand Up @@ -182,7 +182,7 @@ from pydantic import BaseModel, Field


class CategorySchema(BaseModel):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title="CategoryName")
description: str = Field(default="", title="CategoryDescription")

Expand All @@ -194,7 +194,6 @@ class CategorySchema(BaseModel):

```python
from fastapi import FastAPI
from sqlmodel import SQLModel
from fastapi_amis_admin.admin.settings import Settings
from fastapi_amis_admin.admin.site import AdminSite
from fastapi_amis_admin.admin import admin
Expand Down
4 changes: 2 additions & 2 deletions docs/en/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Base(SQLModel):

# Create an SQLModel, see document for details: https://sqlmodel.tiangolo.com/
class Category(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title='CategoryName', max_length=100, unique=True, index=True, nullable=False)
description: str = Field(default='', title='Description', max_length=255)

Expand Down Expand Up @@ -188,7 +188,7 @@ from pydantic import BaseModel, Field


class CategorySchema(BaseModel):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title="CategoryName")
description: str = Field(default="", title="CategoryDescription")

Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/tutorials/basic/Inheritance.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ from fastapi_amis_admin.models.fields import Field

# Create a SQLModel model, please refer to: https://sqlmodel.tiangolo.com/
class Article(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
title: str = Field(title='ArticleTitle', max_length=200)
description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400)
status: bool = Field(None, title='status')
Expand Down
4 changes: 2 additions & 2 deletions docs/en/docs/tutorials/basic/ModelAdmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Model management is the most commonly used management class in background manage
```python
# First create a SQLModel model, please refer to: https://sqlmodel.tiangolo.com/
class Category(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title='CategoryName')
description: str = Field(default='', title='Description')

Expand Down Expand Up @@ -37,7 +37,7 @@ Let's take a look at this simple example-1. It completes the following steps:
```python
# Create a SQLModel model, please refer to: https://sqlmodel.tiangolo.com/
class Article(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
title: str = Field(title='ArticleTitle', max_length=200)
description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400)
status: bool = Field(None, title='status')
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Base(SQLModel):

# 创建SQLModel模型,详细请参考: https://sqlmodel.tiangolo.com/
class Category(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title='CategoryName', max_length=100, unique=True, index=True, nullable=False)
description: str = Field(default='', title='Description', max_length=255)

Expand Down Expand Up @@ -182,7 +182,7 @@ from pydantic import BaseModel, Field


class CategorySchema(BaseModel):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title="CategoryName")
description: str = Field(default="", title="CategoryDescription")

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/docs/tutorials/basic/Inheritance.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class ElementTemplateAdmin(MyJinja2Admin):

```python linenums="1" hl_lines="32"
from fastapi_amis_admin import admin
from fastapi_amis_admin.models.fields import Field
from fastapi_amis_admin.models import Field


# 创建一个SQLModel模型,详细请参考: https://sqlmodel.tiangolo.com/
class Article(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
title: str = Field(title='ArticleTitle', max_length=200)
description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400)
status: bool = Field(None, title='status')
Expand Down
6 changes: 3 additions & 3 deletions docs/zh/docs/tutorials/basic/ModelAdmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
```python
# 先创建一个SQLModel模型,详细请参考: https://sqlmodel.tiangolo.com/
class Category(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title='CategoryName')
description: str = Field(default='', title='Description')

Expand Down Expand Up @@ -38,10 +38,10 @@ class CategoryAdmin(admin.ModelAdmin):
```python
# 创建一个SQLModel模型,详细请参考: https://sqlmodel.tiangolo.com/
class Article(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
title: str = Field(title='ArticleTitle', max_length=200)
description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400)
status: bool = Field(None, title='status')
status: bool = Field(False, title='status')
content: str = Field(title='ArticleContent')
# 关联Category模型,模型定义参考[示例-1]
category_id: Optional[int] = Field(default=None, foreign_key="category.id", title='CategoryId')
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/docs/utils/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ engine = create_engine("sqlite+pysqlite:///amisadmin.db", echo=True, future=True
#### session_maker

```python
self.session_maker: sessionmaker = sessionmaker(self.async_engine, autoflush=False)
self.session_maker: sessionmaker = sessionmaker(self.engine, autoflush=False)
```

### 方法:
Expand Down
6 changes: 3 additions & 3 deletions fastapi_amis_admin/crud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ from typing import Optional
from fastapi import FastAPI
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
from sqlmodel import SQLModel, Field
from fastapi_amis_admin.crud import SQLModelCrud
from fastapi_amis_admin.crud import SqlalchemyCrud


# 1. Create SQLModel model
class Article(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
title: str = Field(title='ArticleTitle', max_length=200)
description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400)
status: bool = Field(None, title='status')
Expand All @@ -34,7 +34,7 @@ database_url = 'sqlite+aiosqlite:///amisadmin.db'
engine: AsyncEngine = create_async_engine(database_url, future=True)

# 3. Register crud route
article_crud = SQLModelCrud(model=Article, engine=engine).register_crud()
article_crud = SqlalchemyCrud(model=Article, engine=engine).register_crud()

app = FastAPI(debug=True)

Expand Down

0 comments on commit 2fffa00

Please sign in to comment.