Git Product home page Git Product logo

lostandfoundservicev2's Introduction

LostAndFoundServiceV2

LostAndFoundService ECNU校园失物招领服务端V2 重构版
主要是为了传承,老学长毕业了,写个详细的文档。

V1 repo : LostFoundDjangoService

[TOC]

目录:
1.服务介绍
2.部署流程
3.上线流程

1.服务介绍

2.部署流程

2.1安装依赖:

pip install -r requirements.txt

安装Nginx, uwsgi, mysql

apt install nginx uwsgi mysql-server

设置mysql utf-8编码

输入下面的命令,打开第一个配置文件

vim /etc/mysql/conf.d/mysql.cnf

在 [mysql] 标签的下一行添加下面的配置

default-character-set=utf8

输入下面的命令,打开第二个配置文件

vim /etc/mysql/mysql.conf.d/mysqld.cnf

找到 [mysqld] 标签,在其下一行添加下面的配置

character-set-server=utf8

配置文件修改成功之后,输入下面的命令重启mysql服务

service mysql restart

重启之后再去查看数据库的默认编码方式

show variables like '%character%';
mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

创建数据库并设置数据库编码

CREATE DATABASE dbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

2.2新建微服务

python manage.py startapp service

在service文件夹下创建urls.py(设置路由)
在models.py对数据库进行设计 在views.py里写好接口,基本的增删改查(create,delete,update,list),遵循django ORM
将models的改动同步到数据库

python manage.py makemigrations
python manage.py migrate

运行调试(仅调试,上线请勿用此方法)

python manage.py runserver {IP}:{PORT}

3.上线流程

需要Nginx,uwsgi支持

创建数据库并设置数据库编码

CREATE DATABASE dbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

同步数据库接口

python manage.py makemigrations
python manage.py migrate

python manage.py collectstatic ####上线:

####关于django admin
创建超级用户

python manage.py createsuperuser

在服务文件夹里配置admin,如./user/admin.py

lostandfoundservicev2's People

Stargazers

 avatar

Watchers

 avatar

Forkers

cqj8660

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.