Creating the Houses App with Django
Explore how to create a new Django Houses app within a Docker container, manage its folders and files, and configure settings and middleware necessary for cross-origin requests. Learn to integrate the app with Django's admin and REST framework while ensuring the app functions properly in the microservices backend environment.
Navigating the Docker container
To create a new app inside an existing or running Docker container, we must first go into the container and locate the service in which we want to create the application. In our case, we have to shell into our backend service inside the Docker container with the following command:
docker-compose exec backend sh
Creating the new app
Once we are inside the backend service in the container, we can start creating the app. Since it is a Django app that we want to create, we can now issue the following command:
django-admin startapp houses
We can also use:
python3 manage.py startapp houses
Any of these will create the Houses app in the backend service inside the Docker container.
The Houses app content
Once the Houses app is created, we'll have a houses folder inside the backendservices1. Let’s look at the contents of the Houses app we've created and what its files and folders do.
migrations/: This Python package inside thehouses/package stores all the changes to our ...