- Personal website :【 Hai Yong 】【 Fishing games 】【 Develop document navigation 】
- 🤟 Interesting and humorous artificial intelligence learning website : Artificial intelligence
- Want to find a little partner to learn and communicate together , Please click on 【 Full stack technology exchange group 】
- Free and practical computer related knowledge question bank : Come in and hang out
Jump straight to the end Participate in comments and send books
Django It's based on Python Of Web frame , Allows you to quickly create efficient Web Applications . It is also known as the frame containing the battery , because Django Provide built-in functionality for all content , Include Django Management interface 、 Default database - SQLlite3 etc. . When you build a web site , You always need a set of similar components : A way to handle user authentication ( register 、 Sign in 、 sign out )、 Website management panel 、 Forms 、 How to upload files, etc .Django Provides you with ready-made components for you to use , It can also be used for rapid development .
Django be based on MVT( Model - View - Templates ) framework .MVT Is a method for developing Web Software design patterns for applications .
MVT The structure has the following three parts ——
Model : The model will act as an interface to the data . It's responsible for maintaining data . It's the logical data structure behind the entire application , To database ( It's usually MySql、Postgres Relational database ) As a representative .
View : The view is the user interface —— What you see in your browser when you render a website . It consists of HTML/CSS/Javascript and Jinja Document representation .
Templates : The template is made by HTML The static part of the output and some special syntax components that describe how to insert dynamic content .
If not installed in your system python3( Depending on your system and operating system configuration ), Please from here install . Try downloading the latest version of python, This time it is python3.6.4.
Be careful stay Linux and Mac Install in Django Is similar to that of , Here I am Windows Show it in , Just open the terminal instead of the command prompt and execute the following command .
install pip
Open a command prompt and enter the following command
python -m pip install -U pip
stay cmd Enter the following command
pip install django
virtualenv env_site
cd env_site
cd Scripts
activate
Install... By giving the following command django
pip install django
Let's examine how to put Django Install to your PC Then use it to create a basic project .
In your PC Start the Django project , Please open the terminal and enter the following command
django-admin startproject Project name
A name will be created projectName New folder for . Use the terminal input command to enter the project
cd Project name
Now run ,
Python manage.py runserver
Now access http://localhost:8000/
Create application
Django Known for its unique and fully managed application architecture . For each function , You can create an application as if it were a completely separate module . This article will take you through how to create a basic application and use it to add functionality .
In your Django Create a basic application in the project , You need to go to include manage.py And enter the directory of commands from there :
python manage.py startapp projectApp
Now you can see your directory structure as follows :
Consider the applications in the project , You need to INSTALLED_APPS Specify the project name in the list , As shown below settings.py in :
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'projectApp'
]
therefore , We finally created an application , But to use url Rendering applications , We need to include the application in our main project , So that you can render the url. Let's explore .
Move to projectName-> projectName -> urls.py And add the following code to the title
from django.urls import include
Now? , stay URL In the pattern list , You need to specify an app name to include your app url. This is the code for it -
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
# Enter the app name in following syntax for this to work
path('', include("projectApp.urls")),
]
Now you can use the default MVT Models are created in your application URL、 Model 、 View etc. , They will be automatically included in your main project .
Django Apps Independence is the main feature of , Each application supports the main project as a separate unit .
This book delivery 3 Ben , In the future, at least three friends will be selected from the new article review area every week to send books , You can continue to pay attention to me : Hai Yong
Content abstract
(1) There is no deep theory , Each chapter is based on examples , Reader's reference book in the source run , You get the same results as in the book .
(2) Focus on Python Data analysis and visualization technology used in the actual operation . Compared with large and comprehensive books and materials , This book can help readers get started as soon as possible , Start project development .
(3) In the book “ Novice question and answer ” and “ A profound ” Columns allow readers to consolidate their knowledge , The lines , Put this to use .
I don't think I can get it , If you want to buy it yourself, you can also refer to this link :https://item.jd.com/12832122.html
【 The way of drawing prizes 】 Bloggers focus on 、 After you like your favorite articles , Comment area : Life is too short , I love Python!!! Bloggers will use crawler code to randomly select 3 People send books !
【 Opening time 】: As of Sunday night 8 spot
List of previous winners :
Endnote :
Artificial intelligence is the study of 、 Developed to simulate 、 The theory of extending and expanding human intelligence 、 Method 、 A new technical science of technology and application systems . ad locum , We only discussed the basic knowledge of artificial intelligence , Want to acquire more knowledge about artificial intelligence , Or just want to participate in a lottery and whore a book every week , You can send me a private letter to join CSDN Official AI communication group
You are welcome to put forward your opinions and suggestions in the comment area !