def primary_key(self, name):
"""
Add a primary key to the model.
This has some special cases, which is why it's not handled like all the other column types.
:param name: Name of column.
:return: None
"""
pk_field = peewee.PrimaryKeyField(primary_key=True)
self.model._meta.primary_key = pk_field
self.model._meta.auto_increment = True
pk_field.add_to_class(self.model, name)
评论列表
文章目录