Django Project - creating my first app
march - 2024
Programming
Summery
This article continues my Django project journey. You can read about setting up Django here. After discovering that the base Django project is like a mini web server and running the default website for the first time, I started my first app. I decided to start by building the HTML/CSS side of the website.
Django defines app as a peice of a porject. a project can have one or many apps but apps are supposed to be one focused concept. An example I will delve into later would be my budget app. The budget app
Django defines app as a piece of a project. A project can have one or many apps, but apps should focus on one concept. An example I will delve into later would be my budget app. The budget app displays all categories with estimates of expenses in the budget and then shows the individual items for the month. For now, let's focus on the home page for my project. I started by creating a page app and setting up a landing page. To create the app, we need to ensure our virtual environment is running and then tell Django we want to create an app. The pages app will be the home of any web page with no Python, so for now, it will be my landing page or index.html if I am not using Python.
- cd c:\py\django-project
- .\scripts\activate - resutlt: (django-prject) c:\py\django-project
- (django-prject) c:\py\django-project: python manage.py startapp pages
The app was ready for code, although I used the Django command to create it. My project didn't know the app existed. To make your app recognize it's there, you must go into the settings.py file located in project/project (notice it's named the same as your project). There, you will see a section called apps. Adding the name of your app there will tell Django where to look.
Take Away - Creating and adding apps in Django is very easy. It allows for easy downloads of third-party apps to connect to your project. This structure also allows for easy delegation of responsibilities in a company where multiple people can work in various apps for a single project.