2017-07-05 22 views
0

Django 1.7で正常に動作しています。私は1.11にアップグレードしようとしています。Django 1.11のアップグレード - オブジェクトに 'password'属性がありません

1.11で次のエラーが表示されていますが、問題が見つからないようです。ここで

は、問題のコードです:

class Profile(models.Model): 
    profile_id = models.CharField(max_length=50, null=True, unique=True, db_index=True) 
    pet_shop_customer_id = models.CharField(max_length=40) 
    django_user = models.OneToOneField(User, to_field='username', parent_link=True, null=True, 
             db_column="django_username", default=None, db_index=True, db_constraint=False) 

私が呼ぶときに問題がある:

profile = Profile.objects.get(profile_id='x') # pulls a valid profile 
print profile.django_user 

私はこのエラーを取得する:

例外値:

'Profile' object has no attribute 'password' 

Exception Location:  /Users/../lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py in <dictcomp>, line 291 
+3

あなたの 'django_user'フィールドには' parent_link = True'があります。 'Profile'モデルは' User'から継承することになっていますか? –

+0

ありがとうございます。私はそれに気付かなかった。それを取り除くことはそれを修正するようだ。 – Greg

答えて

1

を@adrien mentioとしてコメントにned、それが問題だった。 Userに1対1のフィールドでparent_link = Trueを削除する必要がありました。

関連する問題