我正在遵循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)
答案 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)