ユーザーが次にログインしたときに表示できる「通知」を残すシステムを追加しています。models.pyファイルに単純なNotificationクラスを作成しました。このUserInfoクラス(同じmodels.py内)を使用して、socialauthの一部としてDjangoの既存のユーザーシステムにいくつかの属性を追加します。
class UserInfo(models.Model):
user = models.OneToOneField(User, unique=True)
...
reputation = models.IntegerField(null=True, blank=True)
def add_notification(message):
notification = Notification(user=self.user, message=message)
notification.save
コンソールで試してみると、次のようになります。
>>> user = User.objects.get(id=14)
>>> user.userinfo.add_notification('you are an awesome intern!')
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: add_notification() takes exactly 1 argument (2 given)
>>>
ここで何が欠けていますか?私は一種のDjango初心者なので、簡単なことかもしれません。ありがとう!