Skip to content

Commit

Permalink
demo: Add a .env file with the CRISPY_GDS_FRONTEND_VERSION setting
Browse files Browse the repository at this point in the history
  • Loading branch information
StuartMacKay committed Jan 10, 2025
1 parent f9b1568 commit 87dbddc
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The version of the Gov.uk Design System
CRISPY_GDS_FRONTEND_VERSION=5.3.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
# Ignore dot files except those required for the project
.*
!.editorconfig
!.env.example
!.envrc
!.github
!.gitignore
Expand Down
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ release note`_.
7. Copy the .js and .js.map files to ``assets/javascripts``.
8. Edit ``demo/settings.py`` to set ``GDS_VERSION`` to the version you downloaded.

Create a copy of the .env.example file and edit it to set the version number of
the govuk-frontend you downloaded:

.. code-block:: console
cp .env.example .env
Now, setup and run Django:

.. code-block:: console
Expand Down
4 changes: 2 additions & 2 deletions demo/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from crispy_forms_gds.utils import get_frontend_version
from django.conf import settings


def frontend_version(request):
return {"CRISPY_GDS_FRONTEND_VERSION": get_frontend_version()}
return {"CRISPY_GDS_FRONTEND_VERSION": settings.CRISPY_GDS_FRONTEND_VERSION}
8 changes: 8 additions & 0 deletions demo/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import os

import environ # type: ignore

DEMO_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.dirname(DEMO_DIR)

env = environ.Env()

environ.Env.read_env(os.path.join(ROOT_DIR, ".env"))

DEBUG = True
SECRET_KEY = "secret"

Expand Down Expand Up @@ -83,3 +89,5 @@
CRISPY_TEMPLATE_PACK = "gds"

CRISPY_FAIL_SILENTLY = False

CRISPY_GDS_FRONTEND_VERSION = env.str("CRISPY_GDS_FRONTEND_VERSION")
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dev-dependencies = [
"sphinx>=8.1.3",
"tox-uv>=1.1.0",
"tox==4.12.1",
"django-environ>=0.11.2",
]

[tool.bumpversion]
Expand Down
11 changes: 11 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 87dbddc

Please sign in to comment.