inchidi
inchidi
just import it then
inchidi
https://dpaste.de/Doaw#L3
there written 404 not found. try append slash in the url like this http://127.0.0.1:8000/calendar/entry/delete/7/
Renita
https://dpaste.de/Pirt#L3
This is the JavaScript file
Renita
and the path contains: path('entry/delete/<int:pk>', views.delete, name='delete'),
Renita
actually the path should be like: 127.0.0.1:8000/entry/delete/<id>
inchidi
Renita
(env) lobo@lobo-Aspire-E5-575G-5419:~/Documents/2018_Python3_Projects/Saurabh_Projects/CalendarProject$ from django.urls import reverse
from: can't read /var/mail/django.urls
inchidi
inchidi
python manage.py shell
Renita
Yeah i understood now🙈
Renita
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/lobo/Documents/2018_Python3_Projects/Saurabh_Projects/CalendarProject/env/lib/python3.5/site-packages/django/urls/base.py", line 90, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/home/lobo/Documents/2018_Python3_Projects/Saurabh_Projects/CalendarProject/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 622, in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'delete' with no arguments not found. 1 pattern(s) tried: ['entry\\/delete\\/(?P<pk>[0-9]+)$']
inchidi
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/lobo/Documents/2018_Python3_Projects/Saurabh_Projects/CalendarProject/env/lib/python3.5/site-packages/django/urls/base.py", line 90, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/home/lobo/Documents/2018_Python3_Projects/Saurabh_Projects/CalendarProject/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 622, in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'delete' with no arguments not found. 1 pattern(s) tried: ['entry\\/delete\\/(?P<pk>[0-9]+)$']
reverse('delete', args=(7,))
inchidi
Renita
Wait
Renita
That works
inchidi
the output equals with url you are using?
Renita
But then on website it's not working :/
Renita
Like where should I change?
inchidi
you should use the second one
Renita
in urls.py?
inchidi
no in your ajax
Renita
$.ajax({
url: '/calendar/entry/delete/' + id,
method: 'DELETE',
beforeSend: function(xhr){
xhr.setRequestHeader('X-CSRFToken', csrf_token);
},
success: function (resp) {
console.log("Successful");
},
error: function(e){
console.log('Error: '+e);
},
});
console.log(settings.url);
}
Renita
like this?
inchidi
no, remove the /calendar
Renita
It was not there
Renita
I added now
inchidi
uh wait, somehow your code different with the error
Renita
Yeah I haven't added but then too it is displaying the error message
Renita
🙈
inchidi
as you can see here https://dpaste.de/Doaw#L3,6
you are using http://127.0.0.1:8000/calendar/entry/delete/7
Renita
Yeah
Renita
See I'll send you the link again
inchidi
inchidi
Renita
please check this: https://dpaste.de/8gHu#
Renita
:/
inchidi
what you can do is returning "success" response in your view then handle it and do page redirection with javascript
inchidi
why you use ajax for this delete btw? you can just make the button href and point that delete url
Renita
Renita
How can i do that href?
inchidi
change 7 with object id you want to delete which is entry.id
Renita
no not working
inchidi
any error?
Renita
no error.
Renita
but it is not getting deleted
Renita
I think we will have to change in views also
inchidi
Renita
FINALLY!!! Thanks a lot
Renita
So there is no use of ajax right?
Renita
Actually im learning about Django and trying to get familiar with it by building applications.
inchidi
Mahesh
Mahesh
Nd python required for django?
Renita
Mahesh
Me too planning to learn... django
Mahesh
May I proceed?
Mahesh
Renita
Yes
inchidi
How do I do this?
exactly like that, but first step you need to change your response from httpredirect to httpresponse
Renita
Okay then?
Renita
In response a success message, right?
inchidi
Renita
and what about javascriot?
inchidi
using this code, your console will print successful. write redirection there
inchidi
this is how to redirect with js
Mahesh
Wht resources u used for it.
inchidi
Mahesh
inchidi
Which?
pick one, up to you
inchidi
that thing about learning strategies its just a myth, that people like to establish as having a “unique” way of learning, its only bs, since what it does matter are 2 things (or 3):
- Will and discipline
- that the learning is meaningful and has a concrete way of being used