:)
我正在尝试在同一个项目上部署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] ~>
奇怪!是吧?我甚至不确定为什么会发生这种错误。有什么帮助吗?
答案 0 :(得分: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)
答案 1 :(得分:1)
这是因为最新版本的django-notification(版本1.0位于here)被重构并从models.py中删除了create_notice_type ....
这很麻烦因为当前版本的django-avatar和django-postman依赖于create_notice_type ......
所以要解决这个问题,我必须通过以下方式安装先前版本的django通知:
pip install django-notification==0.2