I'm using django-notification
to create notifications. based on it's documention I putted:
url(r'^inbox/notifications/', include(notifications.urls, namespace='notifications')),
in my urls.py
. I generate a notification for test by using this in my views.py:
guy = User.objects.get(username = 'SirSaleh')
notify.send(sender=User, recipient=guy, verb='you visted the site!')
and I can easily get the number of unread notification in this url:
http://127.0.0.1:8000/inbox/notifications/api/unread_count/
it return {"unread_count": 1}
as I want. but with /api/unread_list/
I can not to get the list of notifications and I get this error:
ValueError at /inbox/notifications/
invalid literal for int() with base 10: '<property object at 0x7fe1b56b6e08>'
As I beginner in using django-notifications
any help will be appreciated.
Full TraceBack
Environment:
Request Method: GET Request URL: http://127.0.0.1:8000/inbox/notifications/api/unread_list/
Django Version: 2.0.2 Python Version: 3.5.2 Installed Applications: ['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', 'axes', 'django_otp', 'django_otp.plugins.otp_static', 'django_otp.plugins.otp_totp', 'two_factor', 'invitations', 'avatar', 'imagekit', 'import_export', 'djmoney', 'captcha', 'dal', 'dal_select2', 'widget_tweaks', 'braces', 'django_tables2', 'phonenumber_field', 'hitcount', 'el_pagination', 'maintenance_mode', 'notifications', 'mathfilters', 'myproject_web', 'Order', 'PhotoGallery', 'Search', 'Social', 'UserAccount', 'UserAuthentication', 'UserAuthorization', 'UserProfile'] Installed Middleware: ['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']
Traceback:
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner 35. response = get_response(request)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 128. response = self.process_exception_by_middleware(e, request)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/notifications/views.py" in live_unread_notification_list 164. if n.actor:
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/contrib/contenttypes/fields.py" in get 253. rel_obj = ct.get_object_for_this_type(pk=pk_val)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/contrib/contenttypes/models.py" in get_object_for_this_type 169. return self.model_class()._base_manager.using(self._state.db).get(**kwargs)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py" in get 394. clone = self.filter(*args, **kwargs)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py" in filter 836. return self._filter_or_exclude(False, *args, **kwargs)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/query.py" in _filter_or_exclude 854. clone.query.add_q(Q(*args, **kwargs))
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py" in add_q 1253. clause, _ = self._add_q(q_object, self.used_aliases)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py" in _add_q 1277. split_subq=split_subq,
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py" in build_filter 1215. condition = self.build_lookup(lookups, col, value)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/sql/query.py" in build_lookup 1085. lookup = lookup_class(lhs, rhs)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/lookups.py" in init 18. self.rhs = self.get_prep_lookup()
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/lookups.py" in get_prep_lookup 68. return self.lhs.output_field.get_prep_value(self.rhs)
File "/home/saleh/Projects/myproject_web/lib/python3.5/site-packages/django/db/models/fields/init.py" in get_prep_value 947. return int(value)
Exception Type: ValueError at /inbox/notifications/api/unread_list/ Exception Value: invalid literal for int() with base 10: ''
python3
,Django==2.0.2
, anddjango-notifications-hq==1.4.0
@Selcuk – SirSaleh