雖然我救用戶配置到數據庫中,表UserAndPlace_userprofile沒有指定的列性別
有一個錯誤「用戶配置沒有指定的列性別錯誤」。
這裏是我的models.py
""" UserProfile : user information """
class UserProfile(models.Model):
# User basic inherits : username, password, email
user = models.OneToOneField(User)
# Profile information
nickname = models.CharField(max_length=63, unique=True, null=False)
url = models.URLField(blank=True, null=True)
birth = models.DateField(null=True) # TODO change null = false
gender = models.CharField(max_length=15, null=False)
nation = models.CharField(max_length=63, null=True)
region = models.CharField(max_length=63, null=True)
description = models.TextField(blank=True, null=True)
# ImageField: http://goo.gl/ZQEG4e
avatar = models.ImageField(upload_to='/avatar/')
# Foreign Keys
tag = models.ManyToManyField(TagCloud)
,雖然我測試了它從./python的models.py殼我輸入
> from UserAndPlace.models import *
> u1 = User.objects.get(username="user1")
> u1.username
u'user1'
> p1 = UserProfile(user=u1, gender="female")
> p1.user.username
u'user1'
> p1.gender
u'female'
> p1.save()
OperationalError Traceback (most recent call last)
<ipython-input-9-e08e160cd285> in <module>()
----> 1 p1.save()
....
OperationalError: table UserAndPlace_userprofile has no column named gender
我做蟒蛇manage.py執行syncdb並用來檢查錯誤python manage.py sql UserAndPlace
我該如何解決這個錯誤?
感謝您的幫助提前。
我已經使用'sqlclear'刪除了我的表,但發生了相同的錯誤。我還有什麼,先生? – Sogo
只要輸入它就不會清除它,你需要執行它。嘗試'python manage.py dbshell
我懂了!有用!謝謝先生! – Sogo