Use the django-framework extension¶
Note
The Django extension is compatible with the bare
and ubuntu@22.04
bases.
To use it, include extensions: [ django-framework ]
in your
rockcraft.yaml
file.
Example:
name: example-django
summary: A Django application
description: A rock packing a Django application
version: "0.1"
base: [email protected]
license: Apache-2.0
extensions:
- django-framework
platforms:
amd64:
arm64:
Managing project files with the Django extension¶
The extension will search for a directory named after the rock within the
Rockcraft project directory to transfer it into the rock image. The Django
project should have a directory named after the rock, and the wsgi.py
file within this directory must contain an object named application
to serve as the WSGI entry point.
The following is a typical Rockcraft project that meets this requirement.
+-- example_django
| |-- example_django
| | |-- wsgi.py
| | +-- ...
| |-- manage.py
| |-- migrate.sh
| +-- some_app
| |-- views.py
| +-- ...
|-- requirements.txt
+-- rockcraft.yaml
To override this behaviour and adopt a different project structure, add
the django-framework/install-app
part to install the Django project in
the /django/app
directory within the rock image and update the command
for the django
service to point to the WSGI path of your project.
parts:
django-framework/install-app:
plugin: dump
source: .
organize:
foobar: django/app/foobar
manage.py: django/app/manage.py
stage:
- django/app/foobar
- django/app/manage.py
prime:
- django/app/foobar
- django/app/manage.py