Skip to main content

Translate django model to go struct.

Project description

# Django Model 2 Go Struct

for gorm or other ORM operation.

Depends in go code:

## Install

git clone /django2go.git
cd django2go
python install .

## Usage:



run CMD:

`python model2go app_name`

Example generated go code: [testapp.go](./test_project/testapp.go)

Django model:


class Model1(models.Model):
field1 = models.CharField(max_length=200)
field_with_under_score = models.IntegerField()
fieldWithUpperCase = models.IntegerField()
fieldWith_Case = models.IntegerField()


Generated go struct:


type Model2 struct {
Id int64 `json:"id" gorm:"primary_key"`
Field1 string `json:"field1"`
FieldWithUnderScore int64 `json:"field_with_under_score"`
Fieldwithuppercase int64 `json:"fieldWithUpperCase"`
FieldwithCase int64 `json:"fieldWith_Case"`

// TableName 使用指定的数据库表名
func (Model2) TableName() string {

return TABLE_PREFIX + "model2"



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django2go, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size django2go-0.1.2.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page