Skip to main content
Django is an exceptional choice for building a full-stack Web App in 2024. It stands apart from typical hype cycles and is known for its maturity and stability. Combined with tailwindcss it truly is one of our favourite frameworks. The django-app template gives you a full-stack Web App built with Django and Postgres

Setup

1

Create a virtual environment

2

Install phidata

3

Install docker

Install docker desktop to run your app locally
4

Export your OpenAI key

You can get an API key from here.

Create your codebase

Create your codebase using the django-app template pre-configured with Django and PostgreSQL
This will create a folder named django-app with the following structure:

Set OpenAI Key

Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.

Local Web App

Your codebase comes with a pre-configured Django application connected to a Postgres database. Run it using:
Press Enter to confirm and give a few minutes for the image to download (only the first time). Verify container status and view logs on the docker dashboard.

View your Django App

Open localhost:8000 to view the Django App running locally. django-app-django-local

Django Admin

Open localhost:8000/admin to view the Django admin site. Create an admin user by running:
Log in to the admin panel: django-app-django-admin-local

Build your Web App

The Django Tutorials are a great place to learn about Django, play around and update your Web App to your use case. Here's how to create a simple chat application: 1. Create a new django app
Read more about django apps here
2. Register the chat app Update the 'app/settings.py' file and register the chat
app/settings.py
3. Create views for the chat app Update the chat/views.py file to
chat/views.py
4. Configure URLs Create a file named urls.py in the chat folder:
chat/urls.py
Update the app/urls.py file to:
app/urls.py
5. Create templates Create the HTML templates for the chat interface in the chat/templates/chat folder.
chat/templates/chat/base.html
chat/templates/chat/index.html
6. Open Django App Open localhost:8000/chat/ to view the LLM chat app. django-app-chat-app
If needed, restart the django server using phi ws restart dev:docker:app -y

Delete local resources

Play around and stop the workspace using:

Next

Congratulations on running your Django App locally. Next Steps: