程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Pycharms simple step record of creating Django project

編輯:Python

Catalog

1. Creating a virtual environment

2. Activate the virtual environment

3. install Django

4. stay Django Create project under

5. Create database

6. Check out the project

7. Create application

7. 1. Activate the model

8. Definition URL

summary

1. Creating a virtual environment

First create a new folder

stay PyCharm Switch to this folder in the terminal , Input python -m venv Environment name Creating a virtual environment

  At this time, the folder named DjangoPractice Folder

2. Activate the virtual environment

Input in the terminal Environment name \Scripts\activate Activate the environment , To stop the virtual environment, you can enter deactivate

3. install Django

Enter pip install django

4. stay Django Create project under

  Input django-admin startproject Project name . ( Don't forget this )

At this time, the project has been created under the folder

5. Create database

Input python manage.py migrate

6. Check out the project

Input python manage.py runserver

  Enter the browser and open the website to see the following figure

If you want to change the page to Chinese , Can be in settings.py file

LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'

  It is amended as follows

LANGUAGE_CODE = 'zh-hans'TIME_ZONE = 'Asia/Shanghai'

7. Create application

Open a new terminal window , Activate the virtual environment , perform startapp command

  After the execution, you will find that there are more user Folder

7. 1. Activate the model

  stay settings.py Lieutenant general INSTALLED_APPS Modify as shown in the figure

8. Definition URL

stay user\views.py writes index() function :

stay user Create under directory urls.py

  stay Djangopractice01\urls.py add to url

  The page is displayed as "Hello django"

  Or in another way :

stay user Under the new templates Folder , Build a new one inside user\index.html

  stay views.py writes :

  The following operations remain unchanged , Open the page and see :

summary

This is about PyCharm establish Django The article of the project is introduced here , More about PyCharm establish Django Please search the previous articles of SDN or continue to browse the relevant articles below. I hope you will support SDN more in the future !



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved