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

Automatic platform brick cutting [Django], continuous promotion...

編輯:Python

windows System

  • win The logo +r, Input cmd, Open the command line window

  • Input : python -m pip install virtualenvwrapper-win

  • Open the control panel - Systems and security - System - Advanced system setup - environment variable - System variables - Click New ,

  • Variable name : Input  WORKON_HOME, A variable's value : Enter a custom path , Make sure to save

     

Creating a virtual environment 【virtualenv ll_env】

 

Create a virtual project and activate

start-up virtualenvwrapper.bat after -→  Input cmd, Open the command line window 【mkvirtualenv myproject、workon myproject】

Activate the virtual project and install DJango【 Enter virtual project myproject:  ll_env\Scripts\activate】

【pip install django、django-admin --version】

 

Create a Django project

django-admin startproject face__django .】— Look at the last point { Ensure project structure }

 

【python manage.py runserver】

 

The local browser opens 【127.0.0.1:8000】【 Command window Ctrl+C  Service can be stopped 】

 

Create an 【django-admin startapp loarngin_logs】

A. Association configuration 【loarngin_logs modify models.py】

from django.db import models
# Create your models here.
class Topic(models.Model):
 text = models.CharField(max_length=200)
date_added = models.DateTimeField(auto_now_add=True)
def __str__(self):
 return self.text

B. Association configuration 【learning_log modify settings.py 】

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'learning_logs',
]

c. Migration data command window 【python manage.py makemigrations learning_logs】

To build database 【python manage.py magrate】

Run the application 【python manage.py runserver】

 

--- remarks -- If the page reports an error after startup, it should be due to data incompatibility , Delete data table file , Rebuild data tables and migrate data , Run it again

 


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