# Django

## Step 1: Ensure your app is Dockerised

ToyStack uses docker to deploy your application and will look for a `Dockerfile` in the top-level of your project structure.

You can either use your own `Dockerfile` or use the following template:

```docker
# Use an official Python runtime as a parent image
FROM python:3.12

# Set environment variables for Python
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set the working directory to /code
WORKDIR /code

# Copy only the requirements file
COPY requirements.txt /code/

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy the current directory contents into the container at /code
COPY . /code/

# Expose the port that the app will run on
EXPOSE 8000

# Run the application
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
```

## Step 2: Import your Git repository

Go to the [ToyStack Dashboard](https://dashboard.toystack.ai) and create a new project using your repository.

## Step 3: Input environment variables

{% hint style="info" %}
Please ensure the `Framework Preset` is set to `DOCKER`. The rest of the variables can be set as required for your project.

Also ensure the `PORT` number matches the one specified in your`Dockerfile`
{% endhint %}

For detailed instructions, please see the [Environment Variables](https://docs.toystack.ai/get-started/environment-variables-setup) page.

## Step 4: Choose a plan

<figure><img src="https://3980355268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg3kWmYTC5OSJ5vltL8xU%2Fuploads%2Fi6AxZOCTmXGxRvbBn91g%2FBackend%20plan%20select.png?alt=media&#x26;token=8f59d21d-f559-4466-83eb-db5c5e104ae1" alt=""><figcaption></figcaption></figure>

## Step 5: Deploy

Simply select the branch you want to deploy, its deployment validity and ToyStack will deploy it


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.toystack.ai/backend-quickstarts/django.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
