【发布时间】:2018-12-10 06:53:12
【问题描述】:
我正在使用django-notification 创建通知。基于it's documention我推杆:
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!')
我可以很容易地在这个网址中获得未读通知的数量:
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 请求 URL: 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','监护人', '轴','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','通知','数学过滤器', 'myproject_web'、'订单'、'PhotoGallery'、'搜索'、'社交'、 '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']
追溯:
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/exception.py” 在内部 35. response = get_response(request)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/base.py” 在 _get_response 128. response = self.process_exception_by_middleware(e, request)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/base.py” 在 _get_response 126. response = Wrapped_callback(request, *callback_args, **callback_kwargs)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/notifications/views.py” 在 live_unread_notification_list 中 164.如果n.actor:
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/contrib/contenttypes/fields.py” 在得到 253. rel_obj = ct.get_object_for_this_type(pk=pk_val)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/contrib/contenttypes/models.py” 在 get_object_for_this_type 169. return self.model_class()._base_manager.using(self._state.db).get(**kwargs)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py” 在得到 394. clone = self.filter(*args, **kwargs)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py” 在过滤器中 836. return self._filter_or_exclude(False, *args, **kwargs)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py” 在 _filter_or_exclude 854. clone.query.add_q(Q(*args, **kwargs))
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py” 在 add_q 1253. 子句,_ = self._add_q(q_object, self.used_aliases)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py” 在_add_q 1277. split_subq=split_subq,
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py” 在 build_filter 1215. 条件 = self.build_lookup(lookups, col, value)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py” 在 build_lookup 1085.lookup = lookup_class(lhs, rhs)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/lookups.py” 在 初始化 18. self.rhs = self.get_prep_lookup()
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/lookups.py” 在 get_prep_lookup 中 68.返回self.lhs.output_field.get_prep_value(self.rhs)
文件 “/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/fields/init.py” 在 get_prep_value 947. 返回整数(值)
异常类型:ValueError at /inbox/notifications/api/unread_list/ 异常值:以 10 为基数的 int() 的无效文字:''
【问题讨论】:
-
您的 Python、Django 和 Django 通知版本是什么?
-
python3、Django==2.0.2和django-notifications-hq==1.4.0@Selcuk -
你有完整的回溯吗?
-
@Cole 我刚刚添加了它。
标签: django django-notification