Subscribe to our channel For more Updates.
/ @techemistry1733
Follow Us On Instagram For Updates.
/ cognitive_solution_
#django #djangoframework #djangoproject #python
In this video you will learn about :
How to start basic django server and model/component of project.
_________________________________________________
Django Project Structure and File Structure
Django makes use of a directory structure to arrange different parts of the web application. It creates a project and an app folder for this.
PROJECT FILES :
Project is the name you have given to your project while typing django -admin startproject (project_name). In my case it is TechVidvan. It contains configuration files of the project.
1. _init.py
This is an empty file as you can see below in the image. The function of this file is to tell the Python interpreter that this directory is a package and involvement of this _init.py file in it makes it a python project.
2. settings.py
It contains the Django project configuration.
The setting.py is the most important file, and it is used for adding all the applications and middleware applications. This is the main setting file of the Django project.
3. urls.py
URL is a universal resource locator, it contains all the endpoints that we should have for our website. It is used to provide you the address of the resources (images, webpages, websites, etc) that are present out there on the internet.
In simpler words, this file tells Django that if a user comes with this URL, direct them to that particular website or image whatsoever it is.
This contains several variable names, and if you change the value, your application will work accordingly.
It contains sqlite3 as the default database. We can change this database to Mysql, PostgreSQL, or MongoDB according to the web application we create.
It contains some pre-installed apps and middleware that are there to provide basic functionality.
4. wsgi.py
When you will complete your journey from development to production, the next task is hosting your application. Here you will not be using the Django web server, but the WSGI server will take care of it
WSGI stands for Web Server Gateway Interface, it describes the way how servers interact with the applications.
It is a very easy task, you just have to import middleware according to the server you want to use. For every server, there is Django middleware available that solves all the integration and connectivity issues.
5. asgi.py
ASGI works similar to WSGI but comes with some additional functionality. ASGI stands for Asynchronous Server Gateway Interface. It is now replacing its predecessor WSGI.
1. _init_.py
This file provides the same functionality as that in the _init_.py file in the Django project structure. It is an empty file and does not need any modifications. It just represents that the app directory is a package.
2. admin.py
Admin.py file is used for registering the Django models into the Django administration.
It is used to display the Django model in the Django admin panel. It performs three major tasks:
a. Registering models
b. Creating a Superuser
c. Logging in and using the web application
We will learn more about the admin panel in the next article about Admin Interface.
3. apps.py
Apps.py is a file that is used to help the user include the application configuration for their app.
Users can configure the attributes of their application using the apps.py file.
However, configuring the attributes is a rare task a user ever performs, because most of the time the default configuration is sufficient enough to work with.
4. models.py
Models.py represents the models of web applications in the form of classes. It is considered the most important aspect of the App file structure.
Models define the structure of the database. It tells about the actual design, relationships between the data sets, and their attribute constraints.
5. views.py
Views are also an important part when we talk about the Django app structure. Views provide an interface through which a user interacts with a Django web application. It contains all the views in the form of classes.
We use the concept of Serializers in Django Rest_Framework for making different types of views. Some of these are CustomFilter Views, Class-Based List Views, and Detail Views.
6. urls.py
Urls.py works the same as that of the urls.py in the project file structure. The primary aim being, linking the user’s URL request to the corresponding pages it is pointing to.
You won’t find this under the app files. We create this by clicking on the New file option written on the top, after the Project name.
7. tests.py
Tests.py allows the user to write test code for their web applications. It is used to test the working of the app.
django framework example project
django framework questions
django basic questions
django programming questions
django framework basics
Auf dieser Seite können Sie das Online-Video Python Django Project | Basic Project Setup | Python Django Project Tutorial for Beginners Part 1 | mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer teCHemistry 31 Januar 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 129 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!