django-flatly
Serving flat pages with Django without views and database.
Helps to separate deployment of front- and backend.
Compatibility
django>= 2.0python>= 3.6
Installation
Install the latest release with pip:
pip install django-flatly
Than add a URL to urlpatterns:
# urls.py
urlpatterns = [
...,
# all others urls above - flatly.urls last one to try!
path('', include('flatly.urls')),
]
Quick start
-
In your root template directory create
flatlyfolder. -
Define
FLATLY_TEMPLATE_ROOTsetting:FLATLY_TEMPLATE_ROOT = 'flatly'
-
Any
.htmlfiles you create in yourflatlydirectory will be automatically served. So if you create a new fileflatly/about_us/overview.htmlthen it will be visible at/about-us/overview/.
Note that django-flatly automatically replaces underscores (_)
with dashes (-).
Search path
Suppose you are requesting the page /account/user-profile/,
django-flatly will render the first template that exists:
${FLATLY_TEMPLATE_ROOT}/account/user_profile${FLATLY_TEMPLATE_ROOT}/account/user_profile.html${FLATLY_TEMPLATE_ROOT}/account/user_profile/index.html
Settings
Template root
django-flatly based on Django's get_template function.
So, user can access any template on your website. You can
restrict access to certain templates by adding the path prefix
to the template name before search:
FLATLY_TEMPLATE_ROOT = 'flatly'
Note that flatly folder can be located in both root and
application template directories.
Defaults to flatly.
Template engine
You can restrict the template search to a particular template engine.
FLATLY_ENGINE = 'jinja2'
Defaults to None.
Template caching
By default (when DEBUG is True), the template system
searches, reads and compiles your templates every time
they’re rendered. It's convenient for local development,
because no need to restart the server after adding/removing
templates.
You can enforce template caching:
FLATLY_CACHE_ENABLED = True
The cached Template instance is returned for subsequent
requests to load the same template.
Defaults to True is settings.DEBUG is False.
Extensions
List of file extensions to iterate over all matching files.
FLATLY_EXTENSIONS = ['html', 'jinja2']
Defaults to ['html'].
Metadata
Release files for django-flatly 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-flatly-0.3.1.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_flatly-0.3.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 13.3 kB
Release files / django-flatly-0.3.1.tar.gz
| Download URL | django-flatly-0.3.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1635de525813c162ff5e6e52a471865fb8191d4bafb6d2462dd462e1e51ece9
|
|
BLAKE2b-256 checksum How to use checksums |
104a6d56bb6df397c84e1f6d9068aeb35eaeefc93d41f90d0246f63e37ec463a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / django_flatly-0.3.1-py2.py3-none-any.whl
| Download URL | django_flatly-0.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
72de0a8f27e2a387e3d135e1dbcbc8ae37cffcff834a3ef37c7a44dd99763ec1
|
|
BLAKE2b-256 checksum How to use checksums |
74b42da207ab80757e4d038082e3a87756136c1a36f8164b51f6aa1542684855
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|