Django模型Model自定义表名和字段列名

2018-08-09  本文已影响0人  NTopic
class Book(models.Model):
    id = models.AutoField(name='ID', default=1, primary_key=True)
    name = models.CharField(name='书名', max_length=64, db_column='book_name')
    author = models.ManyToManyField(Author)
    pub_date = models.DateField(name='出版日期')

    def __str__(self):
        return self.name
    
    class Meta:
        db_table = "zt_book"
上一篇下一篇

猜你喜欢

热点阅读