Skip to content

Commit e1f6b2e

Browse files
authored
Merge pull request #671 from farridav/hotfix/fixing_collectstatic
Bootstrap 5 migration, collectstatic fixes, and project modernization
2 parents 03e86fa + 86ce0a3 commit e1f6b2e

125 files changed

Lines changed: 2423 additions & 1431 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ tests/test_app/static/
2121
.python-version
2222
.mypy_cache
2323
.ruff_cache
24-
todo.md
24+
/*.md
25+
!README.md
26+
.claude

AGENTS.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ version-prerelease: ## Bump to next prerelease (for pre-release workflow)
6060
LATEST_RELEASE=$$(printf "$${LATEST_RELEASE_GITHUB}\n$${LATEST_RELEASE_TEST_PYPI}" | sort -V -r | head -n 1); \
6161
uv version $${LATEST_RELEASE} --frozen; \
6262
uv version --bump patch --bump alpha --frozen
63+
64+
65+
download_bootswatch_css: ## Download the Bootswatch CSS and source map files
66+
for theme in default brite cerulean cosmo cyborg darkly flatly journal litera lumen lux materia minty morph pulse quartz sandstone simplex sketchy slate solar spacelab superhero united vapor yeti zephyr; do \
67+
mkdir -p jazzmin/static/vendor/bootswatch/$${theme}; \
68+
curl -s https://bootswatch.com/5/$${theme}/bootstrap.min.css -o jazzmin/static/vendor/bootswatch/$${theme}/bootstrap.min.css; \
69+
curl -s https://bootswatch.com/5/$${theme}/bootstrap.min.css.map -o jazzmin/static/vendor/bootswatch/$${theme}/bootstrap.min.css.map; \
70+
done

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ them as quickly as I would like, but im trying to get through them all now, hope
2121
[![Docs](https://readthedocs.org/projects/django-jazzmin/badge/?version=latest)](https://django-jazzmin.readthedocs.io)
2222
![PyPI download month](https://img.shields.io/pypi/dm/django-jazzmin.svg)
2323
[![PyPI version](https://badge.fury.io/py/django-jazzmin.svg)](https://pypi.python.org/pypi/django-jazzmin/)
24-
![Python versions](https://img.shields.io/badge/python-%3E=3.9-brightgreen)
24+
![Python versions](https://img.shields.io/badge/python-%3E=3.10-brightgreen)
2525
![Django Versions](https://img.shields.io/badge/django-%3E=4.2-brightgreen)
2626
[![Coverage Status](https://coveralls.io/repos/github/farridav/django-jazzmin/badge.svg?branch=main)](https://coveralls.io/github/farridav/django-jazzmin?branch=main)
2727

docs/bugs_and_features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ Some useful links for feature development:
3636
- [https://adminlte.io/themes/v3/index3.html](https://adminlte.io/themes/v3/index3.html)
3737
- [https://adminlte.io/docs/3.0/index.html](https://adminlte.io/docs/3.0/index.html)
3838
- [Font awesome 5.13.0 free icons](https://fontawesome.com/icons?d=gallery&m=free&v=5.0.0,5.0.1,5.0.10,5.0.11,5.0.12,5.0.13,5.0.2,5.0.3,5.0.4,5.0.5,5.0.6,5.0.7,5.0.8,5.0.9,5.1.0,5.1.1,5.2.0,5.3.0,5.3.1,5.4.0,5.4.1,5.4.2,5.13.0,5.12.0,5.11.2,5.11.1,5.10.0,5.9.0,5.8.2,5.8.1,5.7.2,5.7.1,5.7.0,5.6.3,5.5.0,5.4.2)
39-
- [https://getbootstrap.com/docs/4.5/getting-started/introduction/](https://getbootstrap.com/docs/4.5/getting-started/introduction/)
39+
- [https://getbootstrap.com/docs/5.3/getting-started/introduction/](https://getbootstrap.com/docs/5.3/getting-started/introduction/)

docs/configuration.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ JAZZMIN_SETTINGS = {
2222
# Logo to use for your site, must be present in static files, used for login form logo (defaults to site_logo)
2323
"login_logo": None,
2424

25-
# Logo to use for login form in dark themes (defaults to login_logo)
25+
# Logo to use when color scheme is dark (defaults to login_logo)
2626
"login_logo_dark": None,
2727

2828
# CSS classes that are applied to the logo above
@@ -131,6 +131,8 @@ JAZZMIN_SETTINGS = {
131131
"use_google_fonts_cdn": True,
132132
# Whether to show the UI customizer on the sidebar
133133
"show_ui_builder": False,
134+
# Whether to show the theme chooser dropdown in the top navbar
135+
"show_theme_chooser": False,
134136

135137
###############
136138
# Change view #
@@ -343,7 +345,7 @@ class BookAdmin(admin.ModelAdmin):
343345
You can enable a language chooser dropdown using `"language_chooser": True` in your `JAZZMIN_SETTINGS`, we mainly use this for
344346
assisting with translations, but it could be of use to some people in their admin site.
345347

346-
To make proper use of this, please ensure you have internationalisation setup properly, See [https://docs.djangoproject.com/en/3.1/topics/i18n/translation/](https://docs.djangoproject.com/en/3.1/topics/i18n/translation/)
348+
To make proper use of this, please ensure you have internationalisation setup properly, See [https://docs.djangoproject.com/en/stable/topics/i18n/translation/](https://docs.djangoproject.com/en/stable/topics/i18n/translation/)
347349

348350
Namely:
349351

docs/development.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,42 @@
22

33
## Installation
44

5-
This project manages dependencies using [poetry](https://python-poetry.org/)
5+
This project manages dependencies using [uv](https://docs.astral.sh/uv/)
66

7-
Ensure you have poetry installed (`pip install poetry`)
7+
Ensure you have uv installed (see [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/))
88

9-
Then get setup with `poetry install`
9+
Then get setup:
1010

1111
git clone git@github.com:farridav/django-jazzmin.git
12-
poetry install
12+
cd django-jazzmin
13+
make deps
1314

1415
## Running the test project
1516

1617
Setup db tables etc.
1718

18-
python tests/test_app/manage.py migrate
19+
uv run python tests/test_app/manage.py migrate
1920

2021
Generate test data
2122

22-
python tests/test_app/manage.py reset
23+
uv run python tests/test_app/manage.py reset
2324

2425
Run development server (with werkzeug debugger)
2526

26-
python tests/test_app/manage.py runserver_plus
27+
uv run python tests/test_app/manage.py runserver_plus
28+
29+
Or simply use the Makefile:
30+
31+
make test_app
2732

2833
## Running the tests
2934

3035
Tests are run via github actions on any pull request into `main`, and are written for use with the [pytest](https://docs.pytest.org/en/latest/)
3136
framework, we should have good enough tests for you to base your own off of, though where we are lacking, feel free to contribute,
3237
but keep it clean, concise and simple, leave the magic to the wizards.
3338

34-
Run the test suite with your current python interpreter and Django version using `pytest` or target an individual test
35-
with `pytest -k my_test_name`
36-
37-
Run against all supported Python and Django Versions using `tox`
39+
Run the test suite with `make test` or target an individual test
40+
with `uv run pytest -k my_test_name`
3841

3942
## Contribution guidelines
4043

@@ -47,7 +50,7 @@ Run against all supported Python and Django Versions using `tox`
4750

4851
## Coding guidelines
4952

50-
- autoformat your code with [black](https://github.com/psf/black)
53+
- autoformat your code with `make lint` (uses [ruff](https://docs.astral.sh/ruff/))
5154
- When fixing something display related, please bear the following in mind:
5255
- Try fixing the problem using HTML, else CSS, else JS
5356
- Try removing code, else changing code, else adding code

docs/index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ Live demo https://django-jazzmin-test.onrender.com
3232
You can also view the demo app by cloning the repository, and running the following commands:
3333

3434
```bash
35-
poetry install
36-
./tests/test_app/manage.py migrate
37-
./tests/test_app/manage.py reset
38-
./tests/test_app/manage.py runserver_plus
35+
make deps
36+
make test_app
3937
```
4038

4139
## Screenshots

docs/ui_customisation.md

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,57 +21,70 @@ into your settings that will persist these customisations beyond page refresh.
2121
With the ui customiser enabled (see above), you can try out different bootswatch themes, and combine the theme with our
2222
other UI tweaks.
2323

24-
### Dark mode enabled
24+
### Color scheme (light / dark)
2525

26-
If you set `JAZZMIN_UI_TWEAKS["dark_mode_theme"]` to a dark theme, then users that have opted for dark mode on their
27-
device will be served this theme instead of the one in `JAZZMIN_UI_TWEAKS["theme"]`
26+
Any Bootswatch theme can be shown in light or dark. Jazzmin sets Bootstrap’s `data-bs-theme` on the `<html>` element
27+
to `"light"` or `"dark"`, so the same theme adapts to the chosen color scheme.
2828

29-
This is done using `prefers-color-scheme` in the CSS media attribute, see [here](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
30-
for more information on the web standard
29+
- **`default_theme_mode`** in `JAZZMIN_UI_TWEAKS`: `"light"`, `"dark"`, or `"auto"`. With `"auto"`, the scheme follows
30+
the system preference (`prefers-color-scheme`). Default is `"light"`.
31+
- The UI customizer lets users switch between Light, Dark, and System; the choice is stored in `localStorage` and can be
32+
copied into settings via “Show code”.
3133

32-
for example, to use `flatly` for all users that have no preference or prefer light mode, and `darkly` for those who opt
33-
for dark mode on their device:
34+
Example: default to dark, with one theme for everyone:
3435

3536
```python
3637
JAZZMIN_UI_TWEAKS = {
3738
...
3839
"theme": "flatly",
39-
"dark_mode_theme": "darkly",
40+
"default_theme_mode": "dark",
4041
}
4142
```
4243

43-
To force the use of a single theme regardless, just omit `dark_mode_theme` from your `JAZZMIN_UI_TWEAKS`
44+
Example: follow system preference:
4445

45-
You can preview any of the available themes on your site using the UI Customizer (See above), or view them on bootswatch
46-
below
46+
```python
47+
JAZZMIN_UI_TWEAKS = {
48+
...
49+
"theme": "flatly",
50+
"default_theme_mode": "auto",
51+
}
52+
```
4753

48-
### Light themes
54+
**Migration from `dark_mode_theme`:** If you had `dark_mode_theme` set (e.g. `"darkly"`), it is deprecated and no longer used. For the same behaviour (dark theme when the user’s system prefers dark), set `default_theme_mode": "auto"` and remove `dark_mode_theme`. If you do not update your config, Jazzmin will treat existing `dark_mode_theme` as `default_theme_mode": "auto"` and log a deprecation warning.
4955

50-
- default (Standard theme built on top of bootstrap)
56+
You can preview any of the available themes on your site using the UI Customizer (see above), or view them on bootswatch
57+
below.
58+
59+
### Available themes
60+
61+
- default (standard Bootstrap-based theme)
62+
- brite [preview](https://bootswatch.com/brite/)
5163
- cerulean [preview](https://bootswatch.com/cerulean/)
5264
- cosmo [preview](https://bootswatch.com/cosmo/)
65+
- cyborg [preview](https://bootswatch.com/cyborg/)
66+
- darkly [preview](https://bootswatch.com/darkly/)
5367
- flatly [preview](https://bootswatch.com/flatly/)
5468
- journal [preview](https://bootswatch.com/journal/)
5569
- litera [preview](https://bootswatch.com/litera/)
5670
- lumen [preview](https://bootswatch.com/lumen/)
5771
- lux [preview](https://bootswatch.com/lux/)
5872
- materia [preview](https://bootswatch.com/materia/)
5973
- minty [preview](https://bootswatch.com/minty/)
74+
- morph [preview](https://bootswatch.com/morph/)
6075
- pulse [preview](https://bootswatch.com/pulse/)
76+
- quartz [preview](https://bootswatch.com/quartz/)
6177
- sandstone [preview](https://bootswatch.com/sandstone/)
6278
- simplex [preview](https://bootswatch.com/simplex/)
6379
- sketchy [preview](https://bootswatch.com/sketchy/)
64-
- spacelab [preview](https://bootswatch.com/spacelab/)
65-
- united [preview](https://bootswatch.com/united/)
66-
- yeti [preview](https://bootswatch.com/yeti/)
67-
68-
### Dark themes
69-
70-
- darkly [preview](https://bootswatch.com/darkly/)
71-
- cyborg [preview](https://bootswatch.com/cyborg/)
7280
- slate [preview](https://bootswatch.com/slate/)
7381
- solar [preview](https://bootswatch.com/solar/)
82+
- spacelab [preview](https://bootswatch.com/spacelab/)
7483
- superhero [preview](https://bootswatch.com/superhero/)
84+
- united [preview](https://bootswatch.com/united/)
85+
- vapor [preview](https://bootswatch.com/vapor/)
86+
- yeti [preview](https://bootswatch.com/yeti/)
87+
- zephyr [preview](https://bootswatch.com/zephyr/)
7588

7689
Here are some screenshots of the themes in action, Use the UI Customizer (See above) to test them all
7790

@@ -140,12 +153,10 @@ body.theme-darkly p {
140153
}
141154
```
142155

143-
Or to target your `dark_mode_theme` wrap it like this:
156+
To target dark color scheme (when `data-bs-theme="dark"` is set on the document), use:
144157

145158
```css
146-
@media (prefers-color-scheme: dark) {
147-
body.theme-darkly p {
148-
color: pink;
149-
}
159+
html[data-bs-theme="dark"] body.theme-darkly p {
160+
color: pink;
150161
}
151162
```

0 commit comments

Comments
 (0)