/ admin / users / profile /处的OperationalError没有此类列:users_profile.bio

时间:2020-07-03 19:28:35

标签: python django

我正在遵循Python上有关Django的教程,我试图将履历添加到我的用户个人资料页面,但是出现此错误:

OperationalError at /admin/users/profile/
no such column: users_profile.bio

这是我的models.py文件:

from django.contrib.auth.models import User

# Create your models here.
class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    image = models.ImageField(default='default.jpg', upload_to='profile_pics')
    bio = models.TextField(User)


    def __str__(self):
        return f'{self.user.username} Profile'

这是我的admin.py文件:

from django.contrib import admin
from .models import Profile
# Register your models here.

admin.site.register(Profile)

1 个答案:

答案 0 :(得分:0)

只需更改def __str(self):

$ conda install -c file:///home/.../miniconda3/envs/dev-env/conda-bld/ mcm

OR

def __str__(self):
    return str(self.user.user)