Code Monkey home page Code Monkey logo

django-backend-template's Introduction

django-rest-framework 开发模板

为了加速restful接口开发,这里对django-rest-framework常用代码进行整理, 在需要开发新的项目时可以迅速开发出后台接口.

简介

  • 采用docker部署, 方便快速搭建好环境(开发和线上)
  • 合理的布局,无需修改任何配置即可实现线上和开发环境切换

使用

创建项目

django-admin startproject --template=https://github.com/510908220/django-backend-template/archive/4.0.tar.gz project_name

设置数据库容器

docker run --name db -v /var/lib/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=asheashe -d -p 3306:3306 mysql

开发模式

  • 创建数据库:/config/mysql/app.sql
  • docker-compose.yml目录下执行:docker-compose up -d
  • 创建用户:docker-compose run --rm web python manage.py createsuperuser

线上部署

  • 创建数据库:/config/mysql/app.sql
  • docker-compose.prod.yml目录下执行:docker-compose -f docker-compose.prod.yml up -d
  • 创建用户:docker-compose run --rm web python manage.py createsuperuser

展示

我的docker是装在virtualbox下的. 192.168.56.101是虚拟机里系统的ip. 访问http://192.168.56.101/api/可以看到如下界面:

这些api的例子里包含:

  • 分页
  • 过滤
  • 自定义viewset,主要用于对非model资源的抽象.

django-backend-template's People

Contributors

510908220 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.