The Django Project Folder and Files Structure and Architecture 1
Tags: webdev, django, beginners, python
Published: 2023-10-27 21:33:23

## Introduction

Django is an extensive framework of the language Python. Therefore, on this note, it should not be surprising that a Django project will include many significant files and folders if needed. This article will address the default folders and files provided by Django.

You might want to read this article of mine, [How to Create a Django Project and Project](https://hashnode.com/post/clnz8wvxc000209ldacm02n8n), for the project sample that will be examined in this article or, better still, clone it from the GitHub website [Django sample project](https://github.com/chryzcode/django-sample-project).

## Overview of the Django Project

* **Image of the Project**
    
    Below is an image of the Django project and application. Specifically, this is the project's image from a code editor, VSCode.
    


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8g91qrg24a0ut47n74y.png)

### **The Application Folder(**`my_app`**)**

This is a Django application folder, and it is possible to have more than a Django application based on the project's scope, but our sample project is one application-based. It hosts all the files and folders related to the application and even more, if the files are imported into other applications.

* **Migrations folder**
    
    This is the folder where the schema files for creating and updating a database are kept. This is the command for making migrations. `python manage.py makemigrations`
    
    * **The Init file** `__init__.py`
        
        An experienced Python developer should know the work of this file. It is a Python file that marks a directory as a Python package. It is used to initialize the package when imported(i.e., it helps connect files from a Django folder/ application to one another).
        
        This file is for displaying your models on the project admin page. It is always in a Django application by default. It makes it easy for one to test models using a page/form created by the Django framework.
        
* **The Admin file** `admin.py`
    
    This file is for displaying your models on the project admin page. It is always in a Django application by default. It makes it easy for one to test models using a page/form created by the Django framework.
    
* **The Models file** `models.py`
    
    This is where you carve the tables and schema for the project and application database.
    
* **The Tests file** `tests.py`
    
    For writing tests, check for errors and see that the codes run perfectly.
    
    Check one of my articles on [Why Write Tests?](https://chryzcode.hashnode.dev/why-write-tests)
    
* **The Views file** `views.py`
    
    The File for the application functions and rendering/ displaying data content on the project web application.
    

### **The Project Folder(**`my_project`)

The folder that hosts files and folders related to the project in general. All applications in the project must be connected to this folder.

* **The Pycache folder** `__pycache__`
    
    This folder consists of interpreted and optimized versions of codes. When executed, it converts to bytecode and ends with either a `.pyc` or `.pyo` extension.
    
* **The Asynchronous Server Gateway Interface (ASGI) file** `asgi.py`
    
    It is for sending requests to asynchronous-capable Python programming language frameworks and applications. It allows developers to write web applications that can handle multiple requests at once without blocking the main thread.
    
* **The settings file** `settings.py`
    
    This file is where the major configuration of the project and application resides; without it, the project will be unable to run.
    
* **The URLS file** `urls.py`
    
    This file connects all the URL files in the application folder together. It provides different and unique major URL patterns (parameters) for the project.
    
* **The Web Server Gateway Interface (WSGI) file** `wsgi.py`
    
    It is a mediator responsible for communicating between a web server and a Python web application. It explains how the web server communicates with the app and how it can be chained to process a request.
    
* **The SQLite Database.**
    
    The database of the project. It is where the database schema is located.
    
* **The Manage file** `manage.py`
    
    This file powers and engineers Django-based commands when written from the command line(e.g., `python manage.py runserver` , `python manage.py createsuperuser` ).
    

---

**I hope you were able to understand more about the Django project and application folder and file, structure and architecture.**

[**Continuation...**]