Skip to content

Releases: lflxp/djangolang

v0.2.1

05 Jan 04:09
Compare
Choose a tag to compare
v0.2.1 Pre-release
Pre-release
  • 支持model解析
  • 支持django admin界面自动化
  • 支持快速生成go app项目
  • 支持form表单字段类型有:textarea file o2m int,int16,int64 string text select radio multiselect time o2o m2m password

Django-Golang 是一个将 Django 框架用 Golang 语言重新实现的高性能 Web 框架,具有更高的运行时性能和更好的并发支持,非常适合开发高质量、可扩展的 Web 应用程序。如果你想要使用 Golang 构建 Web 应用程序,Django-Golang 是一个不错的选择。

Install

快速安装

cd examples/sample && go run main.go

全功能

cd examples/allinone && go run example.go

完整演示项目

参考 djangolangexamples

package main

import (
	"github.com/lflxp/djangolang"
	"time"

	"github.com/gin-gonic/gin"
)

type Demotest2 struct {
	Id         int64     `xorm:"id pk not null autoincr" name:"id" search:"true"`
	Country    string    `json:"country" xorm:"varchar(255) not null" search:"true"`
	Zoom       string    `json:"zoom" xorm:"varchar(255) not null"`
	Company    string    `json:"company" xorm:"varchar(255) not null"`
	Items      string    `json:"items" xorm:"varchar(255) not null"`
	Production string    `json:"production" xorm:"varchar(255) not null"`
	Count      string    `json:"count" xorm:"varchar(255) not null"`
	Serial     string    `json:"serial" xorm:"varchar(255) not null" search:"true"`
	Extend     string    `json:"extend" xorm:"varchar(255) not null"`
	Files      string    `xorm:"file" name:"file" verbose_name:"上传文件" colType:"file"`
	Times      time.Time `xorm:"times" name:"times" verbose_name:"时间" colType:"time" list:"true" search:"true"`
}

func init() {
	djangolang.RegisterAdmin(new(Demotest2))
}

func main() {
	r := gin.Default()
	r.GET("/", func(c *gin.Context) {
		c.Redirect(301, "/admin/index")
	})

	djangolang.RegisterControllerAdmin(r)
	r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}