Skip to content

Commit ebbcf93

Browse files
author
Mario Colombo
committed
fully support static files serving (also for local dev env)
1 parent f8b577e commit ebbcf93

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ You need to have docker installed on your system to run this project.
1818
```bash
1919
git clone git@github.com:django-cms/django-cms-quickstart.git
2020
cd django-cms-quickstart
21-
docker-compose build
22-
docker-compose run web python manage.py migrate
23-
docker-compose run web python manage.py createsuperuser
24-
docker-compose up
25-
open http://127.0.0.1:8000
21+
docker compose up --force-recreate --build -d
22+
docker compose run web python manage.py migrate
23+
docker compose run web python manage.py createsuperuser
2624
```
2725

28-
For a more complete how-to guide to this project, see [Deploy a new django CMS project using the Divio quickstart
29-
repository](https://docs.divio.com/en/latest/how-to/django-cms-deploy-quickstart/) in the [Divio Developer
30-
Handbook](https://docs.divio.com).
26+
Then open http://django-cms-quickstart.127.0.0.1.nip.io:8000 (or just http://127.0.0.1:8000) in your browser.
3127

3228

3329
## Customising the project
@@ -40,8 +36,16 @@ see sections that can be removed - in each case, the section is noted with a com
4036

4137
Options are also available for using Postgres/MySQL, uWSGI/Gunicorn/Guvicorn, etc.
4238

43-
## Contribution
39+
## Features
40+
41+
### Static Files with Whitenoise
42+
43+
This quickstart demo has a cloud-ready static files setup via django-whitenoise.
4444

45-
This code for this project has been forked from Divio's quickstart repo. We are grateful for their valueable contribution to the code and documentation of this code.
45+
In the containerized cloud the application is not served by a web server like nginx but directly through uwsgi. django-whitenoise is the glue that's needed to serve static files in your application directly through uwsgi.
46+
47+
See the django-whitenoise settings in settings.py and the `quickstart/templates/whitenoise-static-files-demo.html` demo page template that serves a static file.
48+
49+
## Contribution
4650

47-
You can follow the original repo [here](https://github.com/divio/django-cms-divio-quickstart/).
51+
Here is the official django CMS repository: [https://github.com/django-cms/django-cms-quickstart/](https://github.com/django-cms/django-cms-quickstart/).

quickstart/settings.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
# SECURITY WARNING: don't run with debug turned on in production!
1414
DEBUG = os.environ.get('DJANGO_DEBUG') == "True"
1515

16-
DIVIO_DOMAIN = os.environ.get('DOMAIN', '')
17-
DIVIO_DOMAIN_ALIASES = [
18-
d.strip()
19-
for d in os.environ.get('DOMAIN_ALIASES', '').split(',')
20-
if d.strip()
21-
]
22-
ALLOWED_HOSTS = [DIVIO_DOMAIN] + DIVIO_DOMAIN_ALIASES
16+
if DEBUG:
17+
ALLOWED_HOSTS = "*"
2318

2419
# Redirect to HTTPS by default, unless explicitly disabled
2520
SECURE_SSL_REDIRECT = os.environ.get('SECURE_SSL_REDIRECT') != "False"
@@ -40,6 +35,7 @@
4035
'django.contrib.contenttypes',
4136
'django.contrib.sessions',
4237
'django.contrib.messages',
38+
'whitenoise.runserver_nostatic', # http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
4339
'django.contrib.staticfiles',
4440
'django.contrib.sites',
4541

@@ -129,6 +125,7 @@
129125
CMS_TEMPLATES = [
130126
# a minimal template to get started with
131127
('minimal.html', 'Minimal template'),
128+
('whitenoise-static-files-demo.html', 'Static File Demo'),
132129

133130
# optional templates that extend base.html, to be used with Bootstrap 4
134131
('page.html', 'Page'),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% load cms_tags sekizai_tags static %}
2+
<html>
3+
<head>
4+
<title>{% page_attribute "page_title" %}</title>
5+
{% render_block "css" %}
6+
</head>
7+
<body>
8+
{% cms_toolbar %}
9+
10+
<img src="{% static "django-cms-logo.png" %}" \/>
11+
12+
{% placeholder "content" %}
13+
{% render_block "js" %}
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)