2

私はDjangoでプロジェクトを構築しており、現在、ユーザーのアクティビティを追跡する手段としてdjango-notificationを実装しようとしています。私はそれをインストールしていくつかの通知を作成することができましたが、それらは電子メールでのみ送信され、フィードビューに表示できるようにそれぞれのデータベースに保存されていません。

/ notification / feed /は現在、タイプエラーを表示しますが、それが関連しているかどうかわかりませんか?

/ notifys / feed / init()のTypeErrorは、正確に3つの引数を取ります(1つ指定)

何かアドバイスをいただければ幸いです。Pinaxが通知をどのように使用するかを見てきましたが、電子メールのみのバックエンドをどのように超えたかを理解できませんでした。

settings.pyで、「notification」とtemplate_context_processor「notification.context_processors.notification」を有効にしました。

urls.py

    url(r'^note/', include('notification.urls')),

app / management.py

if "notification" in settings.INSTALLED_APPS:
from notification import models as notification

def create_notice_types(app, created_models, verbosity, **kwargs):
    notification.create_notice_type("messages_received", _("Message Received"), _("you have received a message"), default=2)

signals.post_syncdb.connect(create_notice_types, sender=notification)

app / view.py

...      
if notification:
    notification.send([user], "messages_received", {'message': message,})
...

Notification.sendが実行され、これを確認しましたが、「notice」データベースには何も保存されていないようです。

追加する必要があります。私はdjango-notificationのBrianRosnerブランチを実行しています(https://github.com/brosner/django-notification)。

4

1 に答える 1

1

brosnerのdjango-notificationsのフォークは、send_now()実際にはNoticeインスタンスをデータベースに追加せず、デフォルトのEmailBackend通知バックエンドも追加しないという点でjtauberのフォークとは異なるようです。

deliver()が呼び出されたときにNoticeインスタンスを作成する独自の通知バックエンドクラスを作成し、に追加する必要がありNOTIIFICATION_BACKENDSます。

jtauberの動作を複製する(テストされていない)例:

class MyBackend(BaseBackend):
    def deliver(self, recepient, sender, notice_type, extra_context):
        messages = self.get_formatted_messages(["notice.html"],
            notice_type.label, extra_context)
        notice = Notice.objects.create(recipient=recepient,  
            message=messages['notice.html'], notice_type=notice_type, 
            on_site=on_site, sender=sender)
        notice.save()
于 2011-09-12T16:21:59.283 に答える