oshipka/vm_gen/templates/_model_py

23 lines
749 B
Plaintext
Raw Normal View History

2020-06-04 15:24:18 +02:00
[%- if _choice_types %]
from sqlalchemy_utils import ChoiceType
[%- endif %]
2020-07-08 14:38:55 +02:00
class [[ name ]](db.Model, ModelController[% for inherit in interits %], [[ inherit ]][% endfor %]):
2020-06-04 15:24:18 +02:00
[%- include "_model_choice_header_py" %]
[%- include "_model_searchable_header_py" %]
[%- for column in columns %]
[%- if column._type == 'relationship' %]
[%- include "_relationship_py" %]
[%- else %]
[[ column.name ]] = db.Column([[ column._type ]],
[%- if column.default %]default="[[ column.default ]]",[%- endif %]
[%- if column.index %]index=True,[%- endif %])
[%- endif %]
[%- endfor %]
[%- if extra_code %]
[[ extra_code ]]
[%- endif %]