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