1👍
✅
For a quick and dirty answer on django, I’d like to get you started with a simple and probably inadequate approach, but it shows how easy it is to add something like django. We’ll just use the django dev server.
- Make a directory, I called mine
dj
andcd dj
ddev config --auto
- Add to the
.ddev/config.yaml
:
webimage_extra_packages: [python3-django]
hooks:
post-start:
- exec: python3 manage.py runserver 0.0.0.0:8000
- Add
.ddev/docker-compose.django.yaml
:
version: "3.6"
services:
web:
expose:
- 8000
environment:
- HTTP_EXPOSE=80:8000
- HTTPS_EXPOSE=443:8000
healthcheck:
test: "true"
ddev start
ddev ssh
and create a trivial django project:django-admin startproject dj .
- Add to your
dj/settings.py
ALLOWED_HOSTS = ["dj.ddev.site"]
- Exit back out to the host with
ctrl-D
orexit
andddev start
- You should be able to access the trivial project at
https://dj.ddev.site
Note that as you proceed, you’ll probably want to end up starting the django server another way, or more likely actually front it by the ddev-webserver nginx server, which would be more natural (as in https://docs.nginx.com/nginx/admin-guide/web-server/app-gateway-uwsgi-django/). But for now, this is a simple demonstration. Happy to help you as you go along.
👤rfay
Source:stackexchange.com