current position:Home>Django web development 03. Install Django module and create App, operating and closing
Django web development 03. Install Django module and create App, operating and closing
2022-08-06 10:32:27【Jay_fearless】
1. Enter the command in the Pycharm console
pip install django
After that, check for the following two files:
If there are any, the installation is successful.
2. Create a project
1. Determine which directory the project is placed in and enter that folder
2.cmd enters the console
3. Console input execute the following command form
django-admin.exe installation path startproject project name
Example:
C:\Users\13529\PycharmProjects\test01\files>C:\Users\13529\PycharmProjects\test01\venv\Scripts\django-admin.exe startproject mysite
After that, check whether the directory file already has a django project package:
Initial project structure:
3.Django App
A project can have multiple apps, and each app can correspond to a function:
First go to our project folder mysite
in the console in Pycharm, and then enter the following command to create app01
:
python manage.py startapp app01
The created App project structure is basically as follows:
After that, we write a test page function index
in views.py
of app01:
views.py
from django.http import HttpResponsefrom django.shortcuts import render# Create your views here.def index(request):return HttpResponse("Welcome")
Then write a path(URL, function)
in mysite's urls
to form a mapping relationship:
urls.py
from django.urls import pathfrom app01 import viewsurlpatterns = [# path('admin/', admin.site.urls),# www.xxx.com/index -> functionpath('index', views.index),]
4. Django project startup and shutdown
First use the cd command to enter the project path in the console, and then run the following command in the Pycharm console:
python manage.py runserver
After the project is started, we test the following page jumps:
successfully entered the page index
:
Press the Ctrl
+ C
keys to close the project:
copyright notice
author[Jay_fearless],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/218/202208061025005199.html
The sidebar is recommended
- Python's common modules of threading and Thread modules The first stage of thread implementation
- Blender Python Programming: Creating Emitting Materials
- Python multiprocessing
- How does python implement image edge detection
- Django paging method
- django regex
- How does Python represent time?2 modules, 3 ways, 1 text to understand~
- Modify column name and row index in pandas DataFrame
- [python pandas groupby]
- Python Daily Practice (New Question Bank of Niu Ke) - Day 20: Dictionary Practice
guess what you like
[LeetCode brush questions] Hash table - some questions are implemented with built-in functions (with Python code)
[LeetCode brush questions] Linked list topic (1) (with Python code)
[Small case of python learning] Simulation system invasion to enhance interest
Getting Started with Python Basics - Essential Knowledge for Getting Started
How does Python represent time?2 modules, 3 ways, 1 text to get it~
Python office software automation, master openpyxl operation in 5 minutes
Introduction to Python Basics - Variables, Strings
[python2] remove the u in front of the unicode string
How to use the Python Color class to draw text
How to use Asyncio Python web programming
Random recommended
- 27 Python artificial intelligence libraries have been sorted out, it is recommended to collect!
- [Python] Word2Vec predicts what will be left if I subtract 'love' from my 'life'
- When I export a pandas package, there is a problem. If I don't import it, there is no problem. Is this not enough memory?
- Python version 3.7.4 How can I install locust successfully?
- How does python use pyinstaller to package music into exe, that is, play background music when running the packaged program?
- Python use pyinstaller how to wrap up music exe, is to run a packaged program play background music?
- Rescue 007 of graph traversal application, detailed analysis of python version
- 27 Python artificial intelligence libraries have been sorted out, it is recommended to collect~
- pandas DataFrame data filtering (2)
- Python is how to represent time?- two modules, three ways, complete the ~ 1
- The definition of pycharm writing python code
- Problems defining functions in Python
- Python Socket Network Programming
- Django server running error
- Python image processing notes - image matching based on Harris corners (skimage)
- (Thirteen--1) Concurrent programming of python (thread, queue, process, coroutine, process thread coroutine comparison)
- (12) Python's memory management mechanism
- Python crawler entry case day07: Hippopx
- Django reports an error ModuleNotFoundError: No module named 'mysqlclient'
- Python study notes
- How to upgrade python? python3 version and install pip3
- [Python] 4-word summary for amateurs, PyCharm2022.2 Professional Edition improves development efficiency, basic settings and common shortcut keys (super practical) & basic knowledge of Python - CSDN 21-day learning challenge
- [Python Data Science Quick Start Series | 03] Playing with Data Extraction: Numpy Indexing and Slicing
- Python draws a curve experiment with matplotlib
- How to represent unequally spaced values with equally spaced values in Python?
- The principle of python decorator
- Python dictionary usage summary
- How to install python, configure environment variables, and change sources for third-party libraries
- [Conda] python data analysis/deep learning environment configuration windows+conda+jupyter+pytorch
- 【Conda】python environment setup , windows+conda+jupyter+pytorch (English Version)
- [Pandas] A primer on Pandas processing csv file datasets (neural network/machine learning algorithm data preprocessing)
- 100 days proficient in python (basic version) -- the first day: python and vscode environment installation
- How does python solve high concurrency
- Using the python library geopy method calculating the distance between the multiple sets of longitude and latitude
- JavaScript, Python 8x, 29x slower than C++?
- python---SSH connection to linux service
- [reprint] Python - list comprehension
- Python Computer Vision Programming - Chapter 2 Local Image Descriptors
- "Compared to Excel, easy learning Python data analysis," reading notes -- -- -- -- -- - data operation
- Why is a function in the math module opened in python or in the IDE of pycharm, only the definition is not implemented?