1

:)

django-notificationとdjango-avatarを同じプロジェクトにデプロイしようとしていますが、python2 manage.py syncdbを実行すると、次の例外が発生します。

(dispersion)jorge [~/coders/desarrollo/dispersion] ~> python2 manage.py validate
python2 manage.py validate
0 errors found
(dispersion)jorge [~/coders/desarrollo/dispersion] ~> python2 manage.py syncdb
python2 manage.py syncdb
Creating tables ...
Creating table django_comments
Creating table django_comment_flags
Creating table threadedcomments_threadedcomment
Creating table threadedcomments_freethreadedcomment
Creating table threadedcomments_testmodel
Creating table notification_noticetype
Creating table notification_noticesetting
Creating table notification_noticequeuebatch
Creating table announcements_announcement
Creating table announcements_dismissal
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/commands/syncdb.py", line 110, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/sql.py", line 189, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/dispatch/dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/jorge/coders/desarrollo/dispersion/lib/python2.7/site-packages/django_avatar-1.0.5-py2.7.egg/avatar/management/__init__.py", line 9, in create_notice_types
    notification.create_notice_type("avatar_updated", _("Avatar Updated"), _("avatar have been updated"))
AttributeError: 'module' object has no attribute 'create_notice_type'
(dispersion)jorge [~/coders/desarrollo/dispersion] ~> 

変!は?なぜこのエラーが発生するのかさえわかりません。何か助けはありますか?

4

2 に答える 2

2

そうです、create_notice_typeは削除されました。次のようにNoticeTypeのインスタンスを作成するだけです。

# static block:
try:
    notification = get_app( 'notification' )
except ImproperlyConfigured:
    notification = None
..

# in your method:
if notification is not None and "notification" in settings.INSTALLED_APPS:
from django.utils.translation import ugettext_noop as _

message = {

    'user':     settings.DEFAULT_FROM_EMAIL, 
    'comment':  'no comment', 
    'type':     'welcome', 
    'descr':    'my description',
    # ..
}
try:

    notification.send([to_user], "welcome", message)
except NoticeType.DoesNotExist:
    NoticeType.create("welcome", _("Bla Bla"), _("How nice of you to visit our site"))
    notification.send([to_user], "welcome", message)
于 2013-05-28T14:38:27.597 に答える
1

これは、最新バージョンのdjango-notification(ここにあるバージョン1.0 )がリファクタリングされ、models.py...からcreate_notice_typeが削除されたためです。

django-avatarとdjango-postmanの現在のバージョンはcreate_notice_typeに依存しているため、これは厄介です...

したがって、これを解決するには、次の方法で以前のバージョンのdjango通知をインストールする必要がありました。

pip install django-notification==0.2
于 2013-02-12T18:52:44.643 に答える