Skip to content

using django orm separately from django project, 在非django项目中使用django orm.

Notifications You must be signed in to change notification settings

JeffyLu/django-orm-only

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-orm-only


参考了一下网上其他单独使用django orm的方案, 感觉都太麻烦了, 整合一下个人感觉自己的版本最简单, 看一下项目结构:

	django-orm-only/
	├── db
	│   ├── __init__.py
	│   ├── migrations
	│   │   └── __init__.py
	│   └── models.py
	├── manage.py
	└── test.py

简单说明

  • db文件夹里的migrations放的是每次数据表迁移文件.
  • models.py定义数据表.
  • manage.py主要的配置都在这里面.
  • test.py脚本.

测试

迁移数据库
$ python3 manage.py makemigrations

	Migrations for 'db':
	  db/migrations/0001_initial.py:
	    - Create model TestDb

$ python3 manage.py migrate

	Operations to perform:
	  Apply all migrations: db
	Running migrations:
	  Rendering model states... DONE
	  Applying db.0001_initial... OK
测试脚本
$ python3 test.py

	TestDb object

About

using django orm separately from django project, 在非django项目中使用django orm.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages