Can you please help me about django-notification???
I am able to implement it, but stuck in delete from front end using this API
delete/(?P\d+)/
what I suppose to provide in place of (?P\d+)/ , when I call this API
Asked
Active
Viewed 538 times
1

Syed Imran Hassan
- 68
- 8
-
The `id` to delete. – The_Cthulhu_Kid Jan 30 '18 at 06:38
-
please add the code what you have tried – Gowthaman D Jan 30 '18 at 06:45
3 Answers
1
ID is basically notification ID , and problem is that we first convert it using slug function then pass to API, Here is the code of id conversion
def id2slug(id):
return id + 110909

Syed Imran Hassan
- 68
- 8
0
url(r'^delete/(?P<id>\d+)$', views.delete, name='delete'),
def delete(request, id):
if request.method == 'POST':
if request.is_ajax():
member = Member.objects.get(id = id)
member.delete()
messages.info(request, 'Member was deleted successfully!')
return JsonResponse({'data': 'bar'})
for more details https://docs.djangoproject.com/en/1.11/topics/http/urls/

Gowthaman D
- 574
- 7
- 19
-
Thanks for quick replay, but python implementation is already done by module developer, I am just call API from front end, as I provide id in API call it return 400 error, Here is refrence to URL calls https://github.com/django-notifications/django-notifications/blob/master/notifications/urls.py and here is the API call methods https://stackoverflow.com/a/45457260/3796988 – Syed Imran Hassan Jan 30 '18 at 06:59
-
This is my ajax call $.ajax({ type: 'GET', url: "/inbox/notifications/delete/" + msg["id"] + "/", success: function (data) { console.log(data) }, complete: function () { // Schedule the next request when the current one's complete {#setInterval(sendRequest, 15000); // The interval set to 5 seconds#} } }); error GET
/delete/20/ 404 – Syed Imran Hassan Jan 30 '18 at 07:10 -
-
-
error is this http://127.0.0.1:8000/inbox/notifications/delete/16/ 404 (Not Found) previous is short due to comment words limit – Syed Imran Hassan Jan 30 '18 at 07:21
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/164150/discussion-between-syed-imran-hassan-and-gowthaman). – Syed Imran Hassan Jan 30 '18 at 07:26
0
From the readme on github : https://github.com/django-notifications/django-notifications,we can see that the value is not the id thats which it dose not delete when you pass in the id as the 'slug'.
urls.py (from the source code)
...
pattern(r'^delete/(?P<slug>\d+)/$', views.delete, name='delete')
...
Each Notification has a slug property in the Notifications model which you pass to the delete api to delete the notification.

user3412550
- 21
- 4