🍔 Django with a Side of JavaScript 🍟
Posted on Jun 29th, 2021
🗓️ Today’s topics
- Check in with progress on code snippets and flashcards
- Why and how to incorporate JavaScript into your Django application
🎯 Django Duplex Project
Habit Tracker or Code Snippets…continued.
Resources
- Django and AJAX
-
Fetching Data with Ajax and Django -> This article is really helpful. There are really good code examples. Here are the most important bits:
By including the ‘X-Requested-With’ header set to ‘XMLHttpRequest’, the view will be able to check if the request is AJAX or not.
request.headers.get('x-requested-with') == 'XMLHttpRequest'
- Django docs on the above
- Unintrusive JS with Django
⭐ EXTRA/TMI
- jQuery -> This is not something I recommend using right now, but I include it here because a lot of the resources you will encounter about using JavaScript in a web browser will refer to it (like the article on unintrusive js listed immediately above). It is not as popular as it once was, and it is incompatible with a framework like React. But you will sometimes come across it, and you may end up working with it at your job, so you might as well recognize it when you see it and look it up if you ever need it.