update docs

This commit is contained in:
long2ice
2021-06-05 21:23:08 +08:00
parent 77c8b613cb
commit 1fc5407c29
3 changed files with 66 additions and 4 deletions

View File

@ -1 +1,8 @@
# Override builtin pages and widgets
If you want override the builtin pages and widgets template, you can create a template in your own template folders same
path as the builtin.
For example, the path of builtin layout template is `templates/layout.html`, you can create a template also
named `layout.html` and put it in your template folders. The easiest way to override is just to copy the builtin
template content then modify the content yourself.

View File

@ -1 +1,56 @@
# Custom Page
It is easy to create custom pages.
## Template folders
You should configure your template folders when configure `fastapi-admin`.
```python
from fastapi import FastAPI
from fastapi_admin.app import app as admin_app
app = FastAPI()
@app.on_event("startup")
async def startup():
await admin_app.configure(template_folders=["templates"])
```
## Write router
Then write a router to render the template.
```python
from fastapi_admin.app import app as admin_app
from fastapi_admin.template import templates
from starlette.requests import Request
@admin_app.get("/")
async def home(request: Request):
return templates.TemplateResponse("dashboard.html", context={"request": request})
```
Don't forget to create the template `dashboard.html` and write content.
## Register resource
Finally, register it as a `Link` resource.
```python
from fastapi_admin.app import app as admin_app
from fastapi_admin.resources import Link
@admin_app.register
class Dashboard(Link):
label = "Dashboard"
icon = "fas fa-home"
url = "/admin"
```
That's all, if you are a superuser, you can see a menu in navbar now, otherwise you need give the admin permission of
the resource.

View File

@ -1,12 +1,12 @@
# Sponsor
The pro version is just for the sponsors. As a sponsor, you will get source code or be invited
to [fastapi-admin](https://github.com/fastapi-admin) organization as an `outside collaborator with readonly access`, and
you can get the pro features and get updates for a time.
The pro version is just for the sponsors. As a sponsor, you will be invited
to [fastapi-admin](https://github.com/fastapi-admin) organization as an **outside collaborator with readonly access**,
and you can get the pro features and get updates for a time.
## How to become a sponsor
Sponsor Link: <https://sponsor.long2ice.cn>
Sponsor Link: **<https://sponsor.long2ice.cn>**
You can choose any sponsor way you like. After sponsor, you can email me <long2ice@gmail.com> with your GitHub account
and sponsor way and account, then I will invite you to join [fastapi-admin](https://github.com/fastapi-admin)