刚升级到Django 1.4并收到错误消息 [英] Just upgraded to Django 1.4 and getting error with messages

查看:81
本文介绍了刚升级到Django 1.4并收到错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到Django 1.4,它破坏了包括消息传递在内的几项功能。

I just upgraded to Django 1.4 and it has broken a couple things including messaging.

这是我尝试更改头像时遇到的错误:

Here's the error I get when trying to change a avatar:

'User' object has no attribute 'message_set'
Exception Location: /Users/nb/Desktop/myenv2/lib/python2.7/site-packages/django/utils/functional.py in inner, line 185

跟踪:

File "/Users/nb/Desktop/myenv2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/nb/Desktop/myenv2/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  20.                 return view_func(request, *args, **kwargs)
File "/Users/nb/Desktop/spicestore/apps/avatar/views.py" in change
  76.             request.user.message_set.create(
File "/Users/nb/Desktop/myenv2/lib/python2.7/site-packages/django/utils/functional.py" in inner
  185.         return func(self._wrapped, *args)

Exception Type: AttributeError at /avatar/change/
Exception Value: 'User' object has no attribute 'message_set'

此外,消息传递不再有效在网站上。 Django 1.4有哪些更改可能导致此问题,并且有人克服了类似的问题?

Also, messaging no longer works on the site. What are the changes in Django 1.4 that could be causing this and has anyone overcome a similar issue?

推荐答案

Django引入了消息应用程序1.2(发行说明)中,并弃用了旧用户消息API。

Django introduced a messages app in 1.2 (release notes), and deprecated the old user messages API.

在Django 1.4中,旧的message_set API已被完全删除,因此您必须更新代码。如果您遵循消息文档,您应该会发现它很简单

In Django 1.4, the old message_set API has been removed completely, so you'll have to update your code. If you follow the messages docs, you should find it pretty straight forward.

这篇关于刚升级到Django 1.4并收到错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆