In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "Django entry project operation example". In the operation process of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Pip install django
Python-m pip install-- upgrade pip
Default address:
C:\ users\ jack hu\ appdata\ local\ programs\ python\ python37
Create a project
Command: d:\ studt2\ python\ abc > django-admin
Create a project named "first"
D:\ studt2\ python\ abc > django-admin startproject first
Just open the project using PyCharm 2019.2
Introduction of project catalogue
Manage.py
Entry to the command line toolset that interacts with the project, project manager, execution
Python manage.py View all commands
Runserver: start the server (d comes with it)
D:\ studt2\ python\ abc\ first > python manage.py runserver
Http://localhost:8000
Change port to 9999
D:\ studt2\ python\ abc\ first > python manage.py runserver 9999
First directory
A container for a project that contains some of the most basic configurations of the project. The directory name is not recommended.
Wsgi.py
Python server network management interface, interface between application and web server
Basically won't change him.
Settings.py
The general configuration file of the project, which contains various configurations such as database, web application, time, etc.
Urls.py
Url profile
All the addresses (pages) of the django project need us to configure his url ourselves.
Create an application
Python manage.py startapp blog
Note: you cannot create an application with a keyword name
Introduction to application catalogue
Migrations
Data migration (migration) module
Admin.py
The background management system configuration of the application
Apps.py
Some configurations of the application, which will be generated later by Django-1.9
Models.py
Data module, using ORM framework, similar to Models (model) in MVC structure
Tests.py
Automated test module, Django provides automated testing function, where you write test scripts (statements)
Views.py
The module where the code that executes the response is located, and the main place where the code logic is processed
Most of the code in the project is written here.
CODING
Create the first page (response)
1. Edit the views.py file
As shown in the figure:
2. Edit the urls.py file
3. Start. Default port 8000
Command: python manage.py runserver
Browser input:
Http://localhost:8000/index/
Unified Management url
Http://127.0.0.1:8000/bolg/
If you don't add it, you will.
Preliminary use of dtl
Models
Create
D:\ studt2\ python\ myblob > python manage.py makemigrations
Transfer
D:\ studt2\ python\ myblob > python manage.py migrate
D:\ studt2\ python\ myblob > python manage.py sqlmigrate blog 0001
From booktest.models import BookInfo,HeroInfo from django.utils import timezone from datetime import *
This is the end of the content of "Django getting started Project Operation example". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.