Django Generator

BESSER provides a code generator for Django web applications. You can create the application in two ways:

  1. Django App with Admin Panel — A Django application with database models and CRUD functionality, accessible via Django’s admin panel.

  2. Django App with Admin Panel & UI Components (deprecated) — Includes everything from the Admin Panel version, plus predefined user interfaces such as forms and templates.

Note

The Web Modeling Editor supports only the generation of Django apps with the Admin Panel. To generate a Django app with UI Components, you must use the Python API.

See also

For a Django project that goes beyond the template — custom apps, auth, containerisation, tests — the Spec-Driven Agent runs this generator first and then lets an LLM customise the result to a natural-language request.

Changed in version 8.0.0: DjangoGenerator.generate() raises when generation fails, including while updating settings.py, instead of printing the error and returning. It writes under output_dir without changing the process’s working directory, and refuses to replace an existing, non-empty directory that is not a generated Django project (one without manage.py). A default_value that cannot be expressed as a literal of the attribute’s type raises InvalidDefaultValueError, and a method without an implementation that cannot be inferred from the class raises NotImplementedError in the generated code. Inferred bodies (__str__, getters, predicates) take inherited attributes into account. See the release notes.

Check the guidelines below to learn how to generate a Django app depending on your needs:

How to Run the Web Application

After generating the code, you can run the web application locally (either with or without containers) depending on how you configured the generator. Keep in mind that the containerization parameter in the code generator determines whether files for container-based deployment are included.

A. Running without containerization (containerization = False)

Recommendation: Use Python 3.12 or higher for optimal performance.

In this case, you will get a Django project configured to deploy with a SQLite database. Go to the project folder and run the following commands to deploy the web app.

# Install the dependencies
pip install -r requirements.txt

# Prepare the database
python manage.py makemigrations
python manage.py migrate

# Create a superuser account
python manage.py createsuperuser

# Start the development server
python manage.py runserver

B. Running with containerization (containerization = True)

Requirement: Docker Compose

In this case, you will get a Django project configured to deploy using software containers: one for the Django app server and another for the PostgreSQL database. Go to the project folder and run the following command.

# Run docker-compose
docker-compose up

Access the Web Application

Admin panel

To access the admin panel of your web app, open your browser and navigate to:

http://localhost:8000/admin

Login Credentials:
  • If containerized: The default username and password are both admin.

  • If not containerized: Use the username and password you set in Step A (Create a superuser account).

Home page

If you have generated the full web app, you can also check the home page and different forms at:

http://localhost:8000

Example