Skip to content

Commit a8ea284

Browse files
Docs Admin + Config
1 parent ff4009b commit a8ea284

File tree

6 files changed

+103
-10
lines changed

6 files changed

+103
-10
lines changed

doc/advanced.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ Some of the Geometry field types that are available include:
315315
Have a look at https://github.com/pallets-eco/flask-admin/tree/master/examples/geo-alchemy
316316
to get started.
317317

318+
319+
.. _display-map-widgets:
320+
318321
Display map widgets
319322
*******************
320323

@@ -719,6 +722,8 @@ While the wrapped function should accept only one parameter - `ids`::
719722
flash(gettext('Failed to approve users. %(error)s', error=str(ex)), 'error')
720723

721724

725+
.. _raise-exceptions-instead-of-flash:
726+
722727
Raise exceptions instead of flash error messages
723728
------------------------------------------------
724729

doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ API
55
:maxdepth: 2
66

77
mod_base
8+
mod_theme
89
mod_helpers
910
mod_model
1011
mod_form

doc/api/mod_base.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
.. automodule:: flask_admin.base
55

6+
.. better to view Admin class first than BaseView class ..
7+
8+
Admin
9+
-----
10+
11+
.. autoclass:: Admin
12+
:members:
13+
14+
615
Base View
716
---------
817

@@ -12,14 +21,8 @@
1221
.. autoclass:: BaseView
1322
:members:
1423

15-
Default view
16-
------------
24+
Default (Index) view
25+
--------------------
1726

1827
.. autoclass:: AdminIndexView
1928
:members:
20-
21-
Admin
22-
-----
23-
24-
.. autoclass:: Admin
25-
:members:

doc/api/mod_theme.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
``flask_admin.theme``
2+
=====================
3+
4+
.. automodule:: flask_admin.theme
5+
6+
BootstrapTheme
7+
--------------
8+
9+
.. autoclass:: BootstrapTheme
10+
:members:

doc/introduction.rst

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,23 @@ The first step is to initialize an empty admin interface for your Flask app::
5555

5656
app.run()
5757

58-
Here, both the *name* and *theme* parameters are optional. Alternatively,
59-
you could use the :meth:`~flask_admin.base.Admin.init_app` method.
58+
Here, both the *name* and *theme* parameters are optional, have a look to the API
59+
:class:`~flask_admin.base.Admin` for more details about all other parameters.
60+
Alternatively, you could use the :meth:`~flask_admin.base.Admin.init_app` method.
6061

6162
If you start this application and navigate to `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_,
6263
you should see an empty page with a navigation bar on top. Customize the look by
6364
specifying one of the included Bootswatch themes (see https://bootswatch.com/4/ for a preview of the swatches).
65+
Here is list of all available themes:::
66+
67+
all_themes = [
68+
"default", "cerulean", "cosmo", "cyborg", "darkly",
69+
"flatly", "journal", "litera", "lumen", "lux", "materia",
70+
"minty", "pulse", "sandstone", "simplex", "sketchy", "slate",
71+
"solar", "spacelab", "superhero", "united", "yeti"
72+
]
73+
74+
6475

6576
Adding Model Views
6677
------------------
@@ -396,6 +407,56 @@ For this you could override only the view in question, and all the links to it w
396407

397408
return self.render('create_user.html')
398409

410+
411+
Configure Views
412+
---------------
413+
Views can be configured by changing some Environment variables.
414+
415+
416+
=============================== ==============================================
417+
Variable Desctiption
418+
=============================== ==============================================
419+
Geographical Map views To enable use of maps:
420+
421+
``FLASK_ADMIN_MAPS``
422+
423+
Usually Works with:
424+
425+
``FLASK_ADMIN_DEFAULT_CENTER_LAT``
426+
427+
``FLASK_ADMIN_DEFAULT_CENTER_LONG``
428+
429+
Can be integrated with MapBox using:
430+
431+
``FLASK_ADMIN_MAPBOX_MAP_ID``
432+
433+
``FLASK_ADMIN_MAPBOX_ACCESS_TOKEN``
434+
435+
And can use with Google Search with:
436+
437+
``FLASK_ADMIN_MAPS_SEARCH``
438+
439+
``FLASK_ADMIN_GOOGLE_MAPS_API_KEY``
440+
441+
see more :ref:`display-map-widgets`
442+
443+
Exception handling To show exceptions on the output rather than
444+
flash messages:
445+
446+
``FLASK_ADMIN_RAISE_ON_VIEW_EXCEPTION``
447+
448+
``FLASK_ADMIN_RAISE_ON_INTEGRITY_ERROR``
449+
450+
``FLASK_ADMIN_RAISE_ON_INTEGRITY_ERROR``
451+
452+
see more :ref:`raise-exceptions-instead-of-flash`
453+
=============================== ==============================================
454+
455+
**Note:** The ``FLASK_ADMIN_SWATCH``, ``FLASK_ADMIN_FLUID_LAYOUT`` variables are
456+
deprecated and moved to :class:`~flask_admin.theme.BootstrapTheme`
457+
458+
459+
399460
Working With the Built-in Templates
400461
===================================
401462

flask_admin/theme.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ class Theme:
1111

1212
@dataclass
1313
class BootstrapTheme(Theme):
14+
"""
15+
Bootstrap theme for Flask-Admin.
16+
17+
Usage::
18+
19+
t = Bootstrap4Theme(
20+
base_template='my_base.html', # relative your templates folder
21+
swatch='cerulean',
22+
fluid=True
23+
)
24+
admin = Admin(app, name='microblog', theme=t)
25+
"""
26+
1427
folder: typing.Literal["bootstrap4"]
1528
base_template: str = "admin/base.html"
1629
swatch: str = "default"

0 commit comments

Comments
 (0)