我django-notification
用来创建通知。根据我放的文件:
url(r'^inbox/notifications/', include(notifications.urls, namespace='notifications')),
在我的urls.py
. 我通过在我的views.py中使用它来生成一个测试通知:
guy = User.objects.get(username = 'SirSaleh')
notify.send(sender=User, recipient=guy, verb='you visted the site!')
我可以很容易地在这个 url 中获得未读通知的数量:
http://127.0.0.1:8000/inbox/notifications/api/unread_count/
它{"unread_count": 1}
按我的意愿返回。但是/api/unread_list/
我无法获取通知列表,并且收到此错误:
ValueError at /inbox/notifications/
invalid literal for int() with base 10: '<property object at 0x7fe1b56b6e08>'
当我初学者使用django-notifications
任何帮助时,将不胜感激。
全追溯
环境:
请求方式:GET 请求网址: http: //127.0.0.1 :8000/inbox/notifications/api/unread_list/
Django 版本:2.0.2 Python 版本:3.5.2 安装的应用程序:['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django .contrib.messages'、'django.contrib.staticfiles'、'django.contrib.sites'、'django.forms'、'rest_framework'、'allauth'、'allauth.account'、'allauth.socialaccount'、'guardian ','轴','django_otp','django_otp.plugins.otp_static','django_otp.plugins.otp_totp','two_factor','邀请','头像','imagekit','import_export','djmoney', '验证码','dal','dal_select2','widget_tweaks','大括号','django_tables2','phonenumber_field','hitcount','el_pagination','maintenance_mode','notifications','mathfilters','myproject_web','Order','PhotoGallery','Search','Social','UserAccount' , 'UserAuthentication', 'UserAuthorization', 'UserProfile'] 已安装的中间件:['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', ' django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware', 'django_otp.middleware.OTPMiddleware', 'maintenance_mode.middleware.MaintenanceModeMiddleware']
追溯:
内部 35 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/exception.py”。response = get_response(request)
_get_response 128 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/base.py”。response = self.process_exception_by_middleware(e, request)
_get_response 126 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/base.py”。 response = Wrapped_callback(request, *callback_args, **callback_kwargs)
live_unread_notification_list 164 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/notifications/views.py”。如果 n.actor:
获取253中的文件“ /home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/contrib/contenttypes/fields.py”。rel_obj = ct.get_object_for_this_type(pk=pk_val)
get_object_for_this_type 169 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/contrib/contenttypes/models.py”。返回 self.model_class()._base_manager.using(self._state. db).get(**kwargs)
获取 394 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py”。clone = self.filter(*args, **kwargs)
过滤器 836 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py”。返回 self._filter_or_exclude(False, *args, **kwargs)
_filter_or_exclude 854 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py”。clone.query.add_q(Q(*args, **kwargs) )
add_q 1253. 子句中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py”,_ = self._add_q(q_object, self.used_aliases )
_add_q 1277 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py”。 split_subq=split_subq,
build_filter 1215 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py”。条件 = self.build_lookup(lookups, col, value)
build_lookup 1085 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py”。lookup = lookup_class(lhs, rhs)
文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/lookups.py” init 18. self.rhs = self.get_prep_lookup()
get_prep_lookup 68 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/lookups.py”。返回 self.lhs.output_field.get_prep_value(self.rhs)
get_prep_value 947 中的文件“/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/fields/init .py ”。返回 int(value)
异常类型:ValueError at /inbox/notifications/api/unread_list/ 异常值:int() 的无效文字,基数为 10:''