In the previous article, we discussed why apps are important in Django project management? What are the benefits of using Django apps? In this article, we will discuss what are we going to build and how do apps play a vital role in Django projects?
Project outline –
We will build a localhost e-commerce mobile phone website which can show us details like Flipkart. What can be details of a smart phone?
- Brand Name
- Quantity Available
Making app –
From the above list, we can see that brand itself can be a different table in the database. For user’s comfort, Django itself provides SQLite3 database which we will be using during this series. During deployment, we can use a different database. To read more about databases, check out DataBase Management System.
To create an app for brand, run the following command in your terminal
python manage.py startapp brand
Now, brand folder should look like
What these files are?
__init__.py: This is a python package.
admin.py: In python file, we will write code which will be relevant to admin.
models.py: In this python file, we will write code which will be revolving around database handling.
tests.py: In this python file, we can write test codes to test if changes done in our code is working fine or not before including them in our main code.
views.py: In this python file, we will write what should user view on a webpage as name of file suggests.
Migrations: It is a folder which will store all the changes that we will make in database. Initially, it is empty as it contains only
__init__.pyof its own and we haven’t interacted with database yet.
geeks_site/settings.py and in
INSTALLED_APPS, add brand in it. It will integrate brand app to your project geeks_site.
- Django - Creating Apps | Set - 1
- Django Introduction | Set 2 (Creating a Project)
- Creating and Using Serializers - Django REST Framework
- Data Science Apps Using Streamlit
- Creating a Proxy Webserver in Python | Set 1
- Creating a Proxy Webserver in Python | Set 2
- Creating views on Pandas DataFrame | Set - 2
- Django Models | Set - 1
- Django Models | Set - 2
- Django Templates | Set - 1
- Django Templates | Set - 2
- Flask - (Creating first simple application)
- Creating a sorted merged list of two unsorted lists in Python
- Python | Creating a 3D List
- Creating Python Virtual Environment in Windows and Linux
- Creating child process using fork() in Python
- Creating a simple machine learning model
- Creating linear kernel SVM in Python
- Creating a Pandas Series from Dictionary
- Python | Creating tensors using different functions in Tensorflow
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai