Skip to content

Commit cbcd698

Browse files
authored
Add a beginner-friendly tutorial (#549)
* Add a beginner-friendly tutorial * Add a beginner-friendly tutorial * Add a beginner-friendly tutorial * Add a beginner-friendly tutorial * test on python 3.12
1 parent 5ab55c8 commit cbcd698

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+793
-73
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
16+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
1717

1818
services:
1919
mongodb:

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.5.0
5+
rev: v4.6.0
66
hooks:
77
- id: check-added-large-files
88
- id: check-toml
@@ -12,18 +12,18 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: trailing-whitespace
1414
- repo: https://github.com/asottile/pyupgrade
15-
rev: v3.15.0
15+
rev: v3.16.0
1616
hooks:
1717
- id: pyupgrade
1818
args:
1919
- --py38-plus
2020
- repo: https://github.com/astral-sh/ruff-pre-commit
21-
rev: v0.1.14
21+
rev: v0.4.8
2222
hooks:
2323
- id: ruff
2424
args:
2525
- --fix
2626
- repo: https://github.com/psf/black
27-
rev: 24.1.1
27+
rev: 24.4.2
2828
hooks:
2929
- id: black

README.md

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# starlette-admin
22

3-
*Starlette-Admin* is a fast, beautiful and extensible administrative interface framework for Starlette/FastApi applications.
3+
*Fast, beautiful, and extensible administrative interface framework for Starlette & FastApi applications*
4+
45

56
<p align="center">
67
<a href="https://github.com/jowilf/starlette-admin/actions/workflows/test.yml">
@@ -22,11 +23,24 @@
2223

2324
![Preview image](https://raw.githubusercontent.com/jowilf/starlette-admin/main/docs/images/preview.jpg)
2425

26+
## why starlette-admin?
27+
28+
FastAPI has emerged as a popular web framework for building APIs in Python. However, it lacks a mature admin interface
29+
solution like Flask-Admin to quickly manage your data through a user-friendly interface. Although
30+
solutions like Sqladmin and Fastapi-Admin exist, they only work with specific ORMs such as SQLAlchemy and Tortoise ORM.
31+
32+
Starlette-admin was born from the need for a FastAPI admin interface that works with various data layer. It aims
33+
to provide a complete solution for CRUD interfaces regardless of the database backend. Starlette-admin works out of the
34+
box with multiple ORM/ODMs and can also be used with a custom data layer.
35+
2536
## Getting started
2637

2738
* Check out [the documentation](https://jowilf.github.io/starlette-admin).
28-
* Try the [live demo](https://starlette-admin-demo.jowilf.com/). ([Source code](https://github.com/jowilf/starlette-admin-demo))
29-
* Try the several usage examples included in the [/examples](https://github.com/jowilf/starlette-admin/tree/main/examples) folder
39+
* Try
40+
the [live demo](https://starlette-admin-demo.jowilf.com/). ([Source code](https://github.com/jowilf/starlette-admin-demo))
41+
* Follow the [tutorials](https://jowilf.github.io/starlette-admin/tutorials/)
42+
* Try the several usage examples included in
43+
the [/examples](https://github.com/jowilf/starlette-admin/tree/main/examples) folder
3044
* If you find this project helpful or interesting, please consider giving it a star ⭐️
3145

3246
## Features
@@ -48,7 +62,8 @@
4862
* [SQLModel](https://sqlmodel.tiangolo.com/)
4963
* [MongoEngine](http://mongoengine.org/)
5064
* [ODMantic](https://github.com/art049/odmantic/)
51-
* Custom backend ([doc](https://jowilf.github.io/starlette-admin/advanced/base-model-view/), [example](https://github.com/jowilf/starlette-admin/tree/main/examples/custom-backend))
65+
* Custom
66+
backend ([doc](https://jowilf.github.io/starlette-admin/advanced/base-model-view/), [example](https://github.com/jowilf/starlette-admin/tree/main/examples/custom-backend))
5267
- Internationalization
5368

5469
## Installation
@@ -70,9 +85,11 @@ $ poetry add starlette-admin
7085
This is a simple example with SQLAlchemy model
7186

7287
```python
73-
from sqlalchemy import Column, Integer, String, create_engine
88+
from sqlalchemy import create_engine
7489
from sqlalchemy.ext.declarative import declarative_base
90+
from sqlalchemy.orm import Mapped, mapped_column
7591
from starlette.applications import Starlette
92+
7693
from starlette_admin.contrib.sqla import Admin, ModelView
7794

7895
Base = declarative_base()
@@ -83,8 +100,8 @@ engine = create_engine("sqlite:///test.db", connect_args={"check_same_thread": F
83100
class Post(Base):
84101
__tablename__ = "posts"
85102

86-
id = Column(Integer, primary_key=True)
87-
title = Column(String)
103+
id: Mapped[int] = mapped_column(primary_key=True)
104+
title: Mapped[str]
88105

89106

90107
Base.metadata.create_all(engine)
@@ -100,6 +117,7 @@ admin.add_view(ModelView(Post))
100117
# Mount admin to your app
101118
admin.mount_to(app)
102119
```
120+
103121
Access your admin interface in your browser at [http://localhost:8000/admin](http://localhost:8000/admin)
104122

105123
## Third party

docs/assets/favicon.ico

5.12 KB
Binary file not shown.
23.4 KB
Loading
105 KB
Loading
27.6 KB
Loading
30 KB
Loading
Loading
7.98 KB
Loading
48.3 KB
Loading
Loading
Loading
Loading

docs/changelog/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
225225
* Add support for custom object representations in the admin interface with `__admin_repr__`
226226
and `__admin_select2_repr__` by [@jowilf](https://github.com/jowilf)
227227
in [#152](https://github.com/jowilf/starlette-admin/pull/152). The documentation can be
228-
found [here](../tutorial/configurations/modelview/#object-representation)
228+
found [here](../user-guide/configurations/modelview/#object-representation)
229229

230230
### Internals
231231

docs/index.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
# Overview
1+
---
2+
hide:
3+
- navigation
4+
---
25

3-
*Starlette-Admin* is a fast, beautiful and extensible administrative interface framework for Starlette/FastApi applications.
6+
# Starlette-Admin
47

5-
<p align="center">
8+
*Fast, beautiful, and extensible administrative interface framework for Starlette & FastApi applications*
9+
10+
<div align="center">
611
<a href="https://github.com/jowilf/starlette-admin/actions/workflows/test.yml">
712
<img src="https://github.com/jowilf/starlette-admin/actions/workflows/test.yml/badge.svg" alt="Test suite">
813
</a>
@@ -18,14 +23,24 @@
1823
<a href="https://pypi.org/project/starlette-admin/">
1924
<img src="https://img.shields.io/pypi/pyversions/starlette-admin?color=2334D058" alt="Supported Python versions">
2025
</a>
21-
</p>
26+
</div>
27+
![Preview image](https://raw.githubusercontent.com/jowilf/starlette-admin/main/docs/images/preview.jpg)
28+
29+
## why starlette-admin?
2230

23-
![Preview image](./images/preview.jpg)
31+
FastAPI has emerged as a popular web framework for building APIs in Python. However, it lacks a mature admin interface
32+
solution like Flask-Admin to quickly manage your data through a user-friendly interface. Although
33+
solutions like Sqladmin and Fastapi-Admin exist, they only work with specific ORMs such as SQLAlchemy and Tortoise ORM.
34+
35+
Starlette-admin was born from the need for a FastAPI admin interface that works with various data layer. It aims
36+
to provide a complete solution for CRUD interfaces regardless of the database backend. Starlette-admin works out of the
37+
box with multiple ORM/ODMs and can also be used with a custom data layer.
2438

2539
## Getting started
2640

2741
* Check out [the documentation](https://jowilf.github.io/starlette-admin).
2842
* Try the [live demo](https://starlette-admin-demo.jowilf.com/). ([Source code](https://github.com/jowilf/starlette-admin-demo))
43+
* Follow the [tutorials](https://jowilf.github.io/starlette-admin/tutorials/)
2944
* Try the several usage examples included in the [/examples](https://github.com/jowilf/starlette-admin/tree/main/examples) folder
3045
* If you find this project helpful or interesting, please consider giving it a star ⭐️
3146

@@ -70,9 +85,11 @@ $ poetry add starlette-admin
7085
This is a simple example with SQLAlchemy model
7186

7287
```python
73-
from sqlalchemy import Column, Integer, String, create_engine
88+
from sqlalchemy import create_engine
7489
from sqlalchemy.ext.declarative import declarative_base
90+
from sqlalchemy.orm import Mapped, mapped_column
7591
from starlette.applications import Starlette
92+
7693
from starlette_admin.contrib.sqla import Admin, ModelView
7794

7895
Base = declarative_base()
@@ -81,10 +98,10 @@ engine = create_engine("sqlite:///test.db", connect_args={"check_same_thread": F
8198

8299
# Define your model
83100
class Post(Base):
84-
__tablename__ = "posts"
101+
__tablename__ = "posts"
85102

86-
id = Column(Integer, primary_key=True)
87-
title = Column(String)
103+
id: Mapped[int] = mapped_column(primary_key=True)
104+
title: Mapped[str]
88105

89106

90107
Base.metadata.create_all(engine)

0 commit comments

Comments
 (0)