models.py 375 B

12345678910111213
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. # 用户信息
  4. class Profile(models.Model):
  5. # 对应django自带的user
  6. user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
  7. # 贡献度
  8. contribution = models.BigIntegerField()
  9. def __str__(self):
  10. return 'user {}'.format(self.user.username)