私はdjango-notifications
pip経由でインストールし、アプリを自分に追加しましたINSTALLED_APPS
:
INSTALLED_APPS = (
'django.contrib.auth',
...
'notifications',
...
)
URLConfを更新しました:
import notifications
urlpatterns = patterns('',
...
('^inbox/notifications/', include(notifications.urls), namespace='notifications'),
...
)
インストールしたのでsouth
、スキーマを移行します。
$ python manage.py migrate notifications
...
...
$ python manage.py migrate --list
notifications
(*) 0001_initial
(*) 0002_auto__add_field_notification_data
(*) 0003_auto__add_field_notification_unread
(*) 0004_convert_readed_to_unread
(*) 0005_auto__del_field_notification_readed
(*) 0006_auto__add_field_notification_level
...
今、私はDjangoシェルを介して手動で通知を作成しようとしていますが、次のようになっていIntegrityError
ます:
[1]: from django.contrib.auth.models import User
[2]: from notifications import notify
[3]: recipient = User.objects.get(username="admin")
[4]: sender = User.objects.get(username="guest")
[5]: notify.send(sender, verb='A test', recipient=recipient)
...
...
...
IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`myapp`.`notifications_notification`, CONSTRAINT `recipient_id_refs_id_5c79cb54` FOREIGN KEY (`recipient_id`) REFERENCES `auth_user` (`id`))')
どうしたの?両方、recipient
およびテーブルにsender
属していauth_user
ます。どんな助けでも大歓迎です。