在app目录下的admin.py文件下注册modul表名
比如:
model.py
class User(models.Model):
nickname = models.CharField(max_length=30, null=False, verbose_name='昵称', unique=True)
password = models.CharField(max_length=300, null=False, verbose_name='密码')
# phone_number = models.CharField(max_length=11, verbose_name='手机号码', unique=True)
email = models.EmailField(verbose_name='邮箱', null=False, unique=True)
beans = models.FloatField(default=5, verbose_name='鱼豆')
send_counter = models.IntegerField(default=0, verbose_name='赠书量')
recieve_counter = models.IntegerField(default=0, verbose_name='收书量')
class Meta:
db_table = 'user'
verbose_name = '用户表' #保证后台显示中文表名
verbose_name_plural = verbose_name
admin.py
admin.site.register(User)
注册后需要迁移同步到数据库
网友评论