Django by Example study notes, djangoexample
Purpose: I resigned in October 2017 and learned python web development for more than five months. Now, I have submitted my resume for my junior position and practiced projects. Django by example is a very good book. I plan to record some important points in the learning process for reference by myself and others.
System: HP notebook, retain the original win10, and draw a space (400 GB) to install ubuntu 16.04 (dual system installation is also a few twists and turns, before is to follow laruence to learn linux, toss Centos 7, later, we found Fan problems and drive errors. After ubuntu was changed, we encountered a dynamic disk problem under the original win10, backed up data to Baidu's online disk, and changed the dynamic disk to a static disk, later I installed ubuntu with a USB flash drive, and the PCIE reported an error and fan problem. I had a hard time installing sogou's input method for one afternoon. However, I started to like Linux)
Pthon environment:
Ubuntu16.04 comes with python3.5.2
Virtual Environment Construction:
Pip install virtualenv # install virtualenv
Virtualenv venv # create a venv isolation environment. My directory is in/home/clay-chen/django/venv django, which is a directory I created in advance for exercises.
Source/home/clay-chen/django/venv/bin/activate # activate the Virtual Environment
Install Django:
Pip install Django # After the installation is successful, open the python compiling environment and run the following command to check whether the installation is successful:
# Import django. VERSION
Create the first project: # For ease of management, I created a new project folder under the venv directory to place the exercise project file. When creating a project, I need to switch to this directory
Django-admin startproject mysite # The new project name here is mysite, which contains manage. py and a sub-Folder mysite with the same name as the project. The sub-folder with the same name contains the project configuration file and route file.
Link to MySQL: # django comes with SQLite micro-database, but this should not be used in future production. To enhance the exercise, I chose MySQL, which is different from this book.