django-style 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Richard Terry
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-style
3
+ Version: 0.1.0
4
+ Summary: Basic tasteful designs for your Django project
5
+ Author-email: Richard Terry <code@radiac.net>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://radiac.net/projects/django-style/
8
+ Project-URL: Documentation, https://django-style.readthedocs.io/en/latest/
9
+ Project-URL: Source, https://github.com/radiac/django-style
10
+ Project-URL: Bug Tracker, https://github.com/radiac/django-style/issues
11
+ Keywords: django,style,theme
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: Django
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: Django>=4.2
20
+ Dynamic: license-file
21
+
22
+ ## Django Style
23
+
24
+ Basic tasteful designs for your Django project, with sensible defaults.
25
+
26
+ Features:
27
+
28
+ * Themes for plain CSS, Tailwind 4, and Bootstrap 5
29
+ * Mobile support
30
+ * App layout for content with a complex UI
31
+ * Basic menu support
32
+
33
+ This project won't replace a proper design, but can help make your prototypes pretty.
34
+
35
+ Pairs particularly well with [nanodjango](https://github.com/radiac/nanodjango/).
36
+
37
+ ### Example
38
+
39
+ To play with a live example, download
40
+ [example.py](https://raw.githubusercontent.com/radiac/django-style/refs/heads/main/example.py)
41
+ and run with [uv](https://docs.astral.sh/uv/getting-started/installation/):
42
+
43
+ ```
44
+ uvx --with django-style nanodjango run example.py
45
+ ```
46
+
47
+ ### Quickstart
48
+
49
+ 1. Install:
50
+ ```
51
+ pip install django-style
52
+ ```
53
+
54
+ 2. Add it to `INSTALLED_APPS` in your `settings.py`, and optionally configure it:
55
+ ```
56
+ INSTALLED_APPS = [
57
+ ...
58
+ "django_style",
59
+ ]
60
+
61
+ STYLE_THEME = "tailwind" # or "simple" (default) or "bootstrap"
62
+ STYLE_IS_APP = True # enable app layout (default is False)
63
+ ```
64
+
65
+ 3. Extend `base.html` in your templates:
66
+ ```
67
+ {% extends "base.html" %}
68
+ {% block content %}
69
+ <p>Hello world</p>
70
+ {% endblock %}
71
+
72
+
@@ -0,0 +1,51 @@
1
+ ## Django Style
2
+
3
+ Basic tasteful designs for your Django project, with sensible defaults.
4
+
5
+ Features:
6
+
7
+ * Themes for plain CSS, Tailwind 4, and Bootstrap 5
8
+ * Mobile support
9
+ * App layout for content with a complex UI
10
+ * Basic menu support
11
+
12
+ This project won't replace a proper design, but can help make your prototypes pretty.
13
+
14
+ Pairs particularly well with [nanodjango](https://github.com/radiac/nanodjango/).
15
+
16
+ ### Example
17
+
18
+ To play with a live example, download
19
+ [example.py](https://raw.githubusercontent.com/radiac/django-style/refs/heads/main/example.py)
20
+ and run with [uv](https://docs.astral.sh/uv/getting-started/installation/):
21
+
22
+ ```
23
+ uvx --with django-style nanodjango run example.py
24
+ ```
25
+
26
+ ### Quickstart
27
+
28
+ 1. Install:
29
+ ```
30
+ pip install django-style
31
+ ```
32
+
33
+ 2. Add it to `INSTALLED_APPS` in your `settings.py`, and optionally configure it:
34
+ ```
35
+ INSTALLED_APPS = [
36
+ ...
37
+ "django_style",
38
+ ]
39
+
40
+ STYLE_THEME = "tailwind" # or "simple" (default) or "bootstrap"
41
+ STYLE_IS_APP = True # enable app layout (default is False)
42
+ ```
43
+
44
+ 3. Extend `base.html` in your templates:
45
+ ```
46
+ {% extends "base.html" %}
47
+ {% block content %}
48
+ <p>Hello world</p>
49
+ {% endblock %}
50
+
51
+
@@ -0,0 +1,5 @@
1
+ from .utils import Nav, get_base
2
+
3
+ __all__ = ["Nav", "get_base"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,18 @@
1
+ from django.apps import AppConfig
2
+ from django.conf import settings
3
+
4
+
5
+ class StyleConfig(AppConfig):
6
+ name = "django_style"
7
+
8
+ def ready(self):
9
+ # Inject the django_style template context processor
10
+ if hasattr(settings, "TEMPLATES"):
11
+ for template in settings.TEMPLATES:
12
+ if (
13
+ "OPTIONS" in template
14
+ and "context_processors" in template["OPTIONS"]
15
+ ):
16
+ template["OPTIONS"]["context_processors"].append(
17
+ "django_style.context_processors.django_style"
18
+ )
@@ -0,0 +1,6 @@
1
+ # Known themes, for validation
2
+ THEMES = {
3
+ "simple",
4
+ "bootstrap",
5
+ "tailwind",
6
+ }
@@ -0,0 +1,13 @@
1
+ from django.conf import settings
2
+
3
+ from .utils import get_base
4
+
5
+ DEFAULT_THEME = "simple"
6
+
7
+
8
+ def django_style(request):
9
+ theme = getattr(settings, "STYLE_THEME", DEFAULT_THEME)
10
+ return {
11
+ "STYLE_BASE": get_base(theme),
12
+ "STYLE_IS_APP": getattr(settings, "STYLE_IS_APP", False),
13
+ }
@@ -0,0 +1,27 @@
1
+ from django.urls import reverse_lazy
2
+
3
+ from .constants import THEMES
4
+
5
+
6
+ class Nav:
7
+ """
8
+ Describe a navigation item
9
+ """
10
+
11
+ def __init__(self, label: str, view: str):
12
+ self.label = label
13
+ self.view = view
14
+ self.url = reverse_lazy(view)
15
+
16
+
17
+ def get_base(theme: str) -> str:
18
+ """
19
+ Given a theme name, generate the STYLE_BASE value
20
+
21
+ May be useful if wanting to override the STYLE_BASE in a context, eg:
22
+
23
+ render(..., context={"STYLE_BASE": get_base("simple")})
24
+ """
25
+ if theme not in THEMES:
26
+ raise ValueError(f"Unknown django-style theme: {theme}")
27
+ return f"django_style/{theme}/base.html"
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-style
3
+ Version: 0.1.0
4
+ Summary: Basic tasteful designs for your Django project
5
+ Author-email: Richard Terry <code@radiac.net>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://radiac.net/projects/django-style/
8
+ Project-URL: Documentation, https://django-style.readthedocs.io/en/latest/
9
+ Project-URL: Source, https://github.com/radiac/django-style
10
+ Project-URL: Bug Tracker, https://github.com/radiac/django-style/issues
11
+ Keywords: django,style,theme
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: Django
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: Django>=4.2
20
+ Dynamic: license-file
21
+
22
+ ## Django Style
23
+
24
+ Basic tasteful designs for your Django project, with sensible defaults.
25
+
26
+ Features:
27
+
28
+ * Themes for plain CSS, Tailwind 4, and Bootstrap 5
29
+ * Mobile support
30
+ * App layout for content with a complex UI
31
+ * Basic menu support
32
+
33
+ This project won't replace a proper design, but can help make your prototypes pretty.
34
+
35
+ Pairs particularly well with [nanodjango](https://github.com/radiac/nanodjango/).
36
+
37
+ ### Example
38
+
39
+ To play with a live example, download
40
+ [example.py](https://raw.githubusercontent.com/radiac/django-style/refs/heads/main/example.py)
41
+ and run with [uv](https://docs.astral.sh/uv/getting-started/installation/):
42
+
43
+ ```
44
+ uvx --with django-style nanodjango run example.py
45
+ ```
46
+
47
+ ### Quickstart
48
+
49
+ 1. Install:
50
+ ```
51
+ pip install django-style
52
+ ```
53
+
54
+ 2. Add it to `INSTALLED_APPS` in your `settings.py`, and optionally configure it:
55
+ ```
56
+ INSTALLED_APPS = [
57
+ ...
58
+ "django_style",
59
+ ]
60
+
61
+ STYLE_THEME = "tailwind" # or "simple" (default) or "bootstrap"
62
+ STYLE_IS_APP = True # enable app layout (default is False)
63
+ ```
64
+
65
+ 3. Extend `base.html` in your templates:
66
+ ```
67
+ {% extends "base.html" %}
68
+ {% block content %}
69
+ <p>Hello world</p>
70
+ {% endblock %}
71
+
72
+
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ django_style/__init__.py
5
+ django_style/apps.py
6
+ django_style/constants.py
7
+ django_style/context_processors.py
8
+ django_style/utils.py
9
+ django_style.egg-info/PKG-INFO
10
+ django_style.egg-info/SOURCES.txt
11
+ django_style.egg-info/dependency_links.txt
12
+ django_style.egg-info/requires.txt
13
+ django_style.egg-info/top_level.txt
14
+ tests/test_apps.py
15
+ tests/test_settings.py
@@ -0,0 +1 @@
1
+ Django>=4.2
@@ -0,0 +1 @@
1
+ django_style
@@ -0,0 +1,73 @@
1
+ [project]
2
+ name = "django-style"
3
+ description = "Basic tasteful designs for your Django project"
4
+ dynamic = ["version"]
5
+ authors = [
6
+ { name="Richard Terry", email="code@radiac.net" },
7
+ ]
8
+ readme = "README.md"
9
+ license = "BSD-3-Clause"
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Framework :: Django",
13
+ "Programming Language :: Python :: 3",
14
+ "Operating System :: OS Independent",
15
+ ]
16
+ keywords = ["django", "style", "theme"]
17
+ requires-python = ">=3.7"
18
+ dependencies = [
19
+ "Django>=4.2",
20
+ ]
21
+
22
+ [project.urls]
23
+ "Homepage" = "https://radiac.net/projects/django-style/"
24
+ "Documentation" = "https://django-style.readthedocs.io/en/latest/"
25
+ "Source" = "https://github.com/radiac/django-style"
26
+ "Bug Tracker" = "https://github.com/radiac/django-style/issues"
27
+
28
+ [build-system]
29
+ requires = ["setuptools>=61.0"]
30
+ build-backend = "setuptools.build_meta"
31
+
32
+ [tool.setuptools]
33
+ include-package-data = true
34
+
35
+ [tool.setuptools.packages.find]
36
+ include = ["django_style*"]
37
+ exclude = ["docs*", "tests*", "src*", "dist*"]
38
+
39
+ [tool.setuptools.dynamic]
40
+ version = {attr = "django_style.__version__"}
41
+
42
+ [tool.pytest.ini_options]
43
+ addopts = "--cov=django_style --cov-report=term --cov-report=html"
44
+ testpaths = [
45
+ "tests",
46
+ "django_style",
47
+ ]
48
+ pythonpath = [
49
+ ".",
50
+ ]
51
+ DJANGO_SETTINGS_MODULE = "tests.test_project.settings"
52
+
53
+ [tool.coverage.run]
54
+ source = ["django_style"]
55
+
56
+ [tool.ruff]
57
+ line-length = 88
58
+ select = ["E", "F"]
59
+ ignore = [
60
+ "E501", # line length
61
+ ]
62
+ exclude = [
63
+ ".tox",
64
+ ".git",
65
+ "*/static/CACHE/*",
66
+ "docs",
67
+ "node_modules",
68
+ "src",
69
+ "dist",
70
+ ]
71
+
72
+ [tool.djlint]
73
+ profile="django"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ from django.conf import settings
2
+
3
+
4
+ def test_context_processor_added():
5
+ context_processors = settings.TEMPLATES[0]["OPTIONS"]["context_processors"]
6
+ assert "django_style.context_processors.django_style" in context_processors
@@ -0,0 +1,30 @@
1
+ import pytest
2
+ from django.test import override_settings
3
+ from django.test.client import Client
4
+
5
+
6
+ def test_default_settings(client):
7
+ response = client.get("/")
8
+ assert response.status_code == 200
9
+
10
+ context = response.context
11
+ assert context["STYLE_BASE"] == "django_style/simple/base.html"
12
+ assert context["STYLE_IS_APP"] is False
13
+ assert "simple/styles.css" in response.content.decode()
14
+
15
+
16
+ @override_settings(STYLE_THEME="bootstrap", STYLE_IS_APP=True)
17
+ def test_custom_settings_applied(client):
18
+ response = client.get("/")
19
+ assert response.status_code == 200
20
+
21
+ context = response.context
22
+ assert context["STYLE_BASE"] == "django_style/bootstrap/base.html"
23
+ assert context["STYLE_IS_APP"] is True
24
+ assert "bootstrap/styles.css" in response.content.decode()
25
+
26
+
27
+ @override_settings(STYLE_THEME="_undefined")
28
+ def test_unknown_theme_caught(client):
29
+ with pytest.raises(ValueError, match="Unknown django-style theme: _undefined"):
30
+ _ = client.get("/")