python - 自己创建的django package怎么生成模型创建脚本?
高洛峰
高洛峰 2017-04-18 09:30:48
0
2
386
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
PHPzhong

You can write a startproject command yourself
I wrote a flask startproject: mana
The general idea is as follows

  1. Write a project prototype locally (you can add manage.py, User model with Auth)

  2. Then consider the dynamic part (the part of the generated project that may change, such as the project name), and mark the dynamic part with an annotation format similar to #{{ xxx }}

  3. Then write the command (click is recommended). The key is to use python os.walk to traverse your prototype (note the use of absolute paths), copy it to your generated project, and dynamically read the partial file replacement#{{ xxx }}.

  4. So you can

    $ yourcommand startproject YourDjangoProject
    $ cd YourDjangoProject  (你想要的项目原型: 含manage.py, 含基本的User模型)
    $ python manage.py makemigrations
    $ python manage.py migrate
    
    

Cookiecutter is a scaffolding. If you are not satisfied with its function, you can write one yourself.

洪涛

If you want to know how to deal with it, just message me. No one is interested in this problem, and I am too lazy to write how to deal with it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template