I. "Using django2.0 to develop" environment deployment and initialization projects

Source: Internet
Author: User
Tags install django

I. "Using django2.0 to develop" environment deployment and initialization projects

Discover that there is nothing better than the Django series tutorial, so I'm going to write a set of tutorials to teach you how to use django2.0

The entire tutorial is done around a project that focuses on the entire environment and the projects under initialization, as well as some common operations in development
Project Address: Https://gitee.com/ccnv07/django_example

Project Introduction

Probably is to use Python to develop a CMS system, and you know dede,phpcms some similar, you can register, login, have membership system, publish articles, front desk browsing articles, backstage management and other functions.

Environment for development use

The Python version used is 3.6.5, many installation tutorials on the web
The virtual environment uses pipenv, which can be installed with PIP
The Django version is 2.0.
Database using mysql5.6

Installing Django

After you create the virtual environment, execute the following installation command

pipenv install django==2.0
# 查看django的版本python -m django --version> 2.0
Create our Project
django-admin startproject cms

Then found a more CMS directory, it long below this

Connecting to a database

Using the Python.pymysql module
So let's install it first.

pipenv install pymysql

Modify the configuration in the cms/settings.py

# cms/settings.pyDATABASES = {    ‘default‘: {        ‘ENGINE‘: ‘django.db.backends.mysql‘,        ‘NAME‘: ‘cms‘,        ‘USER‘: ‘root‘,        ‘PASSWORD‘: ‘123123‘,        ‘HOST‘: ‘127.0.0.1‘,        ‘PORT‘: 3306,        ‘OPTIONS‘: {            ‘autocommit‘: True        }    }}

Because Django supports MYSQLDB by default, you need to add the following code to make Pymysql the MYSQLDB

# cms/__init__.pyimport pymysqlpymysql.install_as_MySQLdb()
Run a simple server in the development process
cd cms/python manage.py runserver

will prompt the following

is to tell you to start running a development server on 127.0.0.1:8000, exit please press CTRL + C

You can also specify your own port and IP

python manage.py 0.0.0.0:5000

This server can only be used for development and testing and cannot be used to deploy production environments. This command will be used frequently in the subsequent development process, so please keep in mind.

I. "Using django2.0 to develop" environment deployment and initialization projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.