inchidi
just import it then
Guilherme
just import it then
Already imported. I want it to keep running in background.
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
Already imported. I want it to keep running in background.
try use django celery as search engine keyword
Guilherme
try use django celery as search engine keyword
Ok. Thank you very much @Inchidi . I will study about it and try my best to solve this issue.
inchidi
and the path contains: path('entry/delete/<int:pk>', views.delete, name='delete'),
run via shell from django.urls import reverse reverse('delete', args=(7,)) make sure the output is url path your ajax call
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
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]+)$']
Renita
Wait
Renita
That works
inchidi
the output equals with url you are using?
Renita
reverse('delete', args=(7,))
This is giving me output as /entry/delete/7
Renita
But then on website it's not working :/
Renita
Like where should I change?
inchidi
But then on website it's not working :/
you write /calendar/entry/delete/ instead /entry/delete/
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
inchidi
I added now
no dont add it
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
Renita
please check this: https://dpaste.de/8gHu#
inchidi
please check this: https://dpaste.de/8gHu#
looks like your object doesnt exists (Entry with id 7). the redirect wont work too since you call it using ajax
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
How can i do that href?
inchidi
How can i do that href?
<a href="{% url 'delete' 7 %}" class="btn btn-danger">Delete</a>
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
I think we will have to change in views also
true, change 'DELETE' with 'GET'
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.
Mahesh
Nd python required for django?
Mahesh
Me too planning to learn... django
Renita
Wht application u building?.?
A simple calendar application to store various events
Mahesh
May I proceed?
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?
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
Wht resources u used for it.
try these tutorials
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