What video should I make next? Any suggestions? *Write me in comments!* Follow me @: Telegram: t.me/red_eyed_coder_club Twitter: twitter.com/CoderEyed Facebook: fb.me/redeyedcoderclub Help the channel grow! Please Like the video, Comment, SHARE & Subscribe!
This was probably the most straight forward example of handling csrf tokens with ajax yet. Thank you very much for your time and effort. Please consider doing videos about chart.js and django. If you could do a video on Rest framework and front end API polling or something like a chat type app with ajax, it would be great.
Hi, unfortunately. I've just come across an issue. After coding along, step by step, at 41:28 the procedure didn't succeed. I've received the message Forbidden (CSRF token missing or incorrect.): /task/ . Could you guys please give me some help on this? Thanks in advance.
It doesn't work. When I click the button 'create'. Takes me to JSON instead of like you on the same page where next objects are shown. In the browser console show me error ' Content Security Policy... ("default-src")'. I'm at this moment 41:18
I loved your content, thanks. Have a doubt though, if you are appending to the main div each time a new task is created using the succes:append function as in your video, why do you still have that for loop running inside your html template and displaying it there?
Олег, ты тоже тянешь здоровый джейквери... С вью.джс разбираюсь пока(к Джанге кручу его), можешь пример с fetch запросом показать тоже самое? Как туда токен воткнуть и прочее.. не могу сообразить уже второй день как сделать.
Thank you! Very nice tutorial, but can you explain, why you need to send dataId through url, when deleting and completing? You sending it also in POST, but don't use it in view. Isn't it better to make just static endpoint like 'task/delete' and use post data?
I keep getting this error: [01/Nov/2020 11:56:54] "GET /static/js/moviesjs.js HTTP/1.1" 404 1668 [01/Nov/2020 11:56:54] "GET /static/js/moviesjs.js HTTP/1.1" 404 1668 idk why because my urls files are fine so idk what's wrong with my js file?
Thank you, I liked your video... 😊. Small question.. please help me... while serializing.. jquery add extra input text field will it be same or we need to use(i for range method).
hello , thanks for the video , but I have a question about enter key, page directs me to json page when I enter task with enter key. is there any solution for it?
To solve it you can use the 'X-Requested-With: XMLHttpRequest' header, and check its presence in the request on the Django side. If a request has this header Django view will return JSON, otherwise - just an HTML template. I used this approach in this video: th-cam.com/video/xAUOC4Fhb-o/w-d-xo.html
Thanks a lot for this tutorial and for your work. Can you tell me/us how to fix problem, when I want to create new task using enter (not click on button)? After using Enter page redirect on another view with json data. I think problem can be with type="button"...
Thank you. If the action attribute of a form is omitted or its value is empty, browsers will send the form's data to the address that in the moment is in the address bar. Automatically. By default a browser will submit form to the address if: 1) You click on the button with type="submit" attribute or 2) You hit the Enter (Return) button. Unfortunately, there is no neat and succinct solution stackoverflow.com/questions/16062525/disable-enter-submit/16063278 www.hashbangcode.com/article/prevent-enter-key-submitting-forms-jquery
Nice tuts. I want to update the existing data. I liked your solution in creating the data, very neat. But I can't find any neat solution to update existing data. How do I do that?
@@RedEyedCoderClub I found some solution in "simpleisbetterthancomplex.com" but that is not a very precise solution. Is there no other way to do that without using any js library? only using vanilla js as you did?
I used vanilla JS only in the video about getting CSRF_TOKEN from cookies, but to make AJAX requests I used JQuery. And also I used Vue.js in the last video.
@@RedEyedCoderClub Thanks for the reply. But if I want to do the thing only using JQuery it would be certainly helpful because I want to do a just simple CRUD application using one library (JQuery in this case).
the task object is not being saved upon clicking on the card(task.completed not saving as true). I still need to refresh it then click it again before it works.
The problem which is getting for me is that I am being redirected to Json page rather than /task_list_url , why is this happening could you please help me about it?
I have an unspecified number of forms on a page that is the result of a loop on the database. How can I specify which form to send before sending one of these forms to the server using Ajax? In fact, how do I specify which createButton and which createTaskForm? thank you.
I have one doubt, why the csrfmiddlewaretoken was not required for creating the task, and why it's required for editing the task to completed only? As far I can think my answer is, because the serialized data already contained the middlecsrftoken value...... is this correct?
Actually the CSRF token is required for all POST requests. When we use the {% CSRF_TOKEN %} tag in a form, Django will transform this tag to an input tag (hidden). And when we'll serialize the form, the CSRF_TOKEN will get in the object with serialized data. When we create a task - we submit the form. When we update or delete the task - we don't use the form, and so we have to send the CSRF_TOKEN somehow else.
Олег подскажите, а не удобней получать scrf token через cookie? И второй вопрос: будут ли эти все англоязычные уроки на русском вашем канале или может быть платно на patrion(жаль у вас там мало свежего материала я бы обязательно взял подписку!!!)?
Создание заметки происходит только по клику на кнопку. Если нажать Enter, то перекидывает на пустую страницу с json. Не подскажите, как исправить, чтоб и при нажатии Enter и при нажатии на кнопку, Django выполнял одно и то же? Заранее спасибо!
It doesn't work. When I click on submit button, the javascript function isn't call. Nothing happened with ajax. After pressing submit button, the form go the defined url on data_url field with refreshing the page. It's behave normal (like go to view.py function with refreshing the page).
In Django 3.1 the .is_ajax() method was depricated. Try to use special headers like X-HTTP-Request and in a view check it's value. Like I did in this video: th-cam.com/video/xAUOC4Fhb-o/w-d-xo.html
stackoverflow.com/questions/62604556/why-i-get-a-json-page-response-when-its-supposed-not-to-load-the-page-in-django There it is, if you wanna take a look
I've been tired of trying to do ajax with django..... u save my tons of hours.
Thanks 😚😚
Glad you like my videos! Thanks for watching :)
What video should I make next? Any suggestions? *Write me in comments!*
Follow me @:
Telegram: t.me/red_eyed_coder_club
Twitter: twitter.com/CoderEyed
Facebook: fb.me/redeyedcoderclub
Help the channel grow! Please Like the video, Comment, SHARE & Subscribe!
That was just outstanding! Congratulations for your work
Thank you very much!
Siir, it is certainly what I am searching. Thanks God! Thanks a lot!
You're welcome. Thanks for watching.
God this helped so much, all the other tutorials I found were quite out of date, and while still usable, were hard to get my head around
Glad to help. Thanks for watching!
Thank you lot. This what I was searching for long. Thanks alot. ❤️💕
Thank you
thank you so much man really useful I wish the best for you
This was the best basic django with ajax tutorial .....
Thank you!
Thank you! This video was a great learning for me!
Thank you! Glad that my video was useful for you
Amazing video, super well explained thank you 1000! times man.
Thank you! Thanks for watching
tks u so much. finally i finded what i need
Thanks for watching!
Much awaited video. Thanks
Great video mate. Thank you. Saved me alot!!
Thanks for watching!
Amazing tutorial, very simple and nice
Thanks for watching!
This was probably the most straight forward example of handling csrf tokens with ajax yet. Thank you very much for your time and effort. Please consider doing videos about chart.js and django. If you could do a video on Rest framework and front end API polling or something like a chat type app with ajax, it would be great.
Thank you!
My last video is about Django REST + Vue
th-cam.com/video/7GWKv03Osek/w-d-xo.html
And thanks for your suggestions. I'll do it.
great job man. You saved me ! top ++++++++++++
Thank you!
so helpful, thank you so much!
Thanks for watching and your comment!
Incredible. Thanks you so much for this video.
Thanks for watching!
Excelent video. It really help me a lot! Thank you so much!
Glad you like it. Thanks for watching!
Hi, unfortunately. I've just come across an issue. After coding along, step by step, at 41:28 the procedure didn't succeed. I've received the message Forbidden (CSRF token missing or incorrect.): /task/
. Could you guys please give me some help on this? Thanks in advance.
May be it's better now to use Vue.js
Super. Thank you very much for lesson!!!
Thanks for watching!
Very good!
Thank you!
It doesn't work. When I click the button 'create'. Takes me to JSON instead of like you on the same page where next objects are shown. In the browser console show me error ' Content Security Policy... ("default-src")'. I'm at this moment 41:18
Check your code, please
Thanks a lot (spasibo). You really helped me !) Awesome channel)
Thanks for comment!
I loved your content, thanks. Have a doubt though, if you are appending to the main div each time a new task is created using the succes:append function as in your video, why do you still have that for loop running inside your html template and displaying it there?
It's for initial GET request.
When a User get the page at first time.
Very Good!
Thank you!
Олег, ты тоже тянешь здоровый джейквери... С вью.джс разбираюсь пока(к Джанге кручу его), можешь пример с fetch запросом показать тоже самое? Как туда токен воткнуть и прочее.. не могу сообразить уже второй день как сделать.
th-cam.com/video/Zx0TbDDidsw/w-d-xo.html
😆 я как раз по этому видосу вчера вечером разобрался что к чему 👍🏻, спасибо 😉 🙏
Thank you! Very nice tutorial, but can you explain, why you need to send dataId through url, when deleting and completing? You sending it also in POST, but don't use it in view. Isn't it better to make just static endpoint like 'task/delete' and use post data?
yep, it'll be better, and easier.
Much thanks man
Thank you :)
I keep getting this error:
[01/Nov/2020 11:56:54] "GET /static/js/moviesjs.js HTTP/1.1" 404 1668
[01/Nov/2020 11:56:54] "GET /static/js/moviesjs.js HTTP/1.1" 404 1668
idk why because my urls files are fine so idk what's wrong with my js file?
Check your code, please
Thank you, I liked your video... 😊. Small question.. please help me... while serializing.. jquery add extra input text field will it be same or we need to use(i for range method).
Thanks for comment!
hello , thanks for the video , but I have a question about enter key, page directs me to json page when I enter task with enter key.
is there any solution for it?
To solve it you can use the 'X-Requested-With: XMLHttpRequest' header, and check its presence in the request on the Django side. If a request has this header Django view will return JSON, otherwise - just an HTML template.
I used this approach in this video:
th-cam.com/video/xAUOC4Fhb-o/w-d-xo.html
Спасибо большое за урок ))
Thank you :)
Thanks a lot for this tutorial and for your work. Can you tell me/us how to fix problem, when I want to create new task using enter (not click on button)?
After using Enter page redirect on another view with json data. I think problem can be with type="button"...
Thank you.
If the action attribute of a form is omitted or its value is empty, browsers will send the form's data to the address that in the moment is in the address bar. Automatically.
By default a browser will submit form to the address if:
1) You click on the button with type="submit" attribute
or
2) You hit the Enter (Return) button.
Unfortunately, there is no neat and succinct solution
stackoverflow.com/questions/16062525/disable-enter-submit/16063278
www.hashbangcode.com/article/prevent-enter-key-submitting-forms-jquery
stackoverflow.com/questions/21743850/enter-key-to-submit-ajax-form
@@RedEyedCoderClub thank you for your feedback 👍👏💪
thank you!
Thanks for watching!
А как поменять вьюшку таким образом, чтоб перечёркнутое раньше дело назад становилось незачёркнутым? Спасибо
The same way - check the value and set the CSS for it
Thanks bro I liked it ❤
Nice tuts. I want to update the existing data. I liked your solution in creating the data, very neat. But I can't find any neat solution to update existing data. How do I do that?
It's a simple, but full CRUD application.
If you look for concise solution, I think that Vue.js is best for such tasks.
@@RedEyedCoderClub I found some solution in "simpleisbetterthancomplex.com" but that is not a very precise solution. Is there no other way to do that without using any js library? only using vanilla js as you did?
I used vanilla JS only in the video about getting CSRF_TOKEN from cookies, but to make AJAX requests I used JQuery. And also I used Vue.js in the last video.
@@RedEyedCoderClub Thanks for the reply. But if I want to do the thing only using JQuery it would be certainly helpful because I want to do a just simple CRUD application using one library (JQuery in this case).
Well Done
Thank you!
Why didn't you added edit feature to the task?
just forgot about it
@@RedEyedCoderClub are you going to add soon?
Don't you want to do it yourself for practice purposes?
@@RedEyedCoderClub right now I'm working on other things so will do it soon when I get some time.
the task object is not being saved upon clicking on the card(task.completed not saving as true). I still need to refresh it then click it again before it works.
Check you code
thank you
Thanks for watching
The problem which is getting for me is that I am being redirected to Json page rather than /task_list_url , why is this happening could you please help me about it?
try to check the headers or to use the is_ajax() method
excellent
Thank you
I have an unspecified number of forms on a page that is the result of a loop on the database. How can I specify which form to send before sending one of these forms to the server using Ajax?
In fact, how do I specify which createButton and which createTaskForm?
thank you.
Thank you
I have one doubt, why the csrfmiddlewaretoken was not required for creating the task, and why it's required for editing the task to completed only?
As far I can think my answer is, because the serialized data already contained the middlecsrftoken value...... is this correct?
Actually the CSRF token is required for all POST requests.
When we use the {% CSRF_TOKEN %} tag in a form, Django will transform this tag to an input tag (hidden). And when we'll serialize the form, the CSRF_TOKEN will get in the object with serialized data.
When we create a task - we submit the form. When we update or delete the task - we don't use the form, and so we have to send the CSRF_TOKEN somehow else.
@@RedEyedCoderClub Thanks for your reply, now I understand it completely.
🤗🤗
It's great!
@44:45 do not give all cards the same id, css ids must be unique please correct that
I know that CSS id should be unique. It's just an example.
I thought each task has a different id
why not create a task when I press Enter button on my keyboard?
try to use the submit event handler
Want more Django project. From Bangladesh
Just a quick question, why did you use dataType: "json" in the last request, and not the previous ones !?
I just forgot about it. It's not necessary - it will work without dataType: "json"
Олег подскажите, а не удобней получать scrf token через cookie? И второй вопрос: будут ли эти все англоязычные уроки на русском вашем канале или может быть платно на patrion(жаль у вас там мало свежего материала я бы обязательно взял подписку!!!)?
Thanks for comment!
Создание заметки происходит только по клику на кнопку.
Если нажать Enter, то перекидывает на пустую страницу с json.
Не подскажите, как исправить, чтоб и при нажатии Enter и при нажатии на кнопку, Django выполнял одно и то же?
Заранее спасибо!
ответ нашёл сам, если кому надо, то надо заменить
$("#searchButton").click(function () {
на
$("#searchForm").on('submit', (event) => {
Thanks for comment!
It doesn't work. When I click on submit button, the javascript function isn't call. Nothing happened with ajax. After pressing submit button, the form go the defined url on data_url field with refreshing the page. It's behave normal (like go to view.py function with refreshing the page).
In Django 3.1 the .is_ajax() method was depricated. Try to use special headers like X-HTTP-Request and in a view check it's value.
Like I did in this video:
th-cam.com/video/xAUOC4Fhb-o/w-d-xo.html
Everything is working fine, but at time I hit the button create, it responses me with a Json page, how can I fix it?
It depends on what you have written. Please, upload your code to Githab or Gitlab or Bitbucket, and I'll look at it
Can i put it on stack overflow?
stackoverflow.com/questions/62604556/why-i-get-a-json-page-response-when-its-supposed-not-to-load-the-page-in-django There it is, if you wanna take a look
My code is working.
Did his answer solve your problem?
@@RedEyedCoderClub it didn't, i'm still stuck, even though i follow along with your tutorial
Video was amazing but can you please make this only using vanilla javascript 😚😚
It'll be not cross-browser solution. There is nothing bad in using JQuery.
@@RedEyedCoderClub You are right but now days people are avoiding using jQuery and moving towards vanilla javascript.
Steam uses JQuery on their website. And it's ok.
@@RedEyedCoderClub So is it still useful to learn jQuery in 2020 ??
not sure. And of cause it's better to know vanilla JS, than don't know it.
I think that the good idea is to learn a JS framework. Vue.js for example.
Молчанов?
yep, it's him
how to prevent redundancy?
By creating separate function
Олег Молчанов?
yep!
@@RedEyedCoderClub thank you for your videos, they are very helpful in learning python
Thank you!
Олег Молчанов топ
Thank you!
Kindly send sourcecode GitHub link for education purpose
Sorry, but for educational purposes it's better to write code
Смотрел тебя на русском, решил посмотреть ютуб на английском и всё равно смотрю тебя..
USD 5 for the code, it would be better if you just open it
it's opened. The video is free, and you can write the source code yourself. Everyone knows, that laziness costs money.
"very nice tutorial my friend", speak in Valorant - Sova's accent
Thank you!
please post the code on github
Thanks for comment