Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django example #550

Open
williamhbell opened this issue Jan 29, 2025 · 0 comments
Open

Django example #550

williamhbell opened this issue Jan 29, 2025 · 0 comments

Comments

@williamhbell
Copy link

The https://github.com/docker/awesome-compose/blob/master/official-documentation-samples/django/README.md example instructions fail with

docker compose run web django-admin startproject composeexample .
...
  File "/usr/local/lib/python3.13/site-packages/django/core/management/commands/startproject.py", line 2, in <module>
    from django.core.management.templates import TemplateCommand
  File "/usr/local/lib/python3.13/site-packages/django/core/management/templates.py", line 1, in <module>
    import cgi
ModuleNotFoundError: No module named 'cgi'

The cgi module was removed from Python, such that django crashes when used with the latest official Python Docker image. The Dockerfile base image should be specified to avoid this issue. For example:

# syntax=docker/dockerfile:1
FROM python:3.11
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant