If you use the $.ajax
function, you can simply add the csrf
token in the data body:
$.ajax({
data: {
somedata: 'somedata',
moredata: 'moredata',
csrfmiddlewaretoken: '{{ csrf_token }}'
},
More Related Contents:
- How do I integrate Ajax with Django applications?
- Where’s my JSON data in my incoming Django request?
- Any way to make {% extends ‘…’ %} conditional? – Django
- Forbidden (403) CSRF verification failed. Request aborted. Even using the {% csrf_token %}
- CSRF verification failed. Request aborted
- Rendering JSON objects using a Django template after an Ajax call
- CSRF Token missing or incorrect
- Serve a dynamically generated image with Django
- Creating a JSON response using Django and Python
- Mac OS X – EnvironmentError: mysql_config not found
- Target WSGI script cannot be loaded as Python module
- How to compare dates in Django templates
- How to limit the maximum value of a numeric field in a Django model?
- Django [Errno 13] Permission denied: ‘/var/www/media/animals/user_uploads’
- PicklingError: Can’t pickle : it’s not the same object as decimal.Decimal
- multiple databases and multiple models in django
- Creating a list of dictionaries with same keys? [duplicate]
- How do I perform query filtering in django templates
- Django gives Bad Request (400) when DEBUG = False
- Django — Can’t get static CSS files to load
- Django: Calculate the Sum of the column values through query
- How to disable Django’s CSRF validation?
- How to update an existing Conda environment with a .yml file
- What is an efficient way of inserting thousands of records into an SQLite table using Django?
- Dynamically creating classes – Python
- What is the difference between static files and media files in Django?
- PyCharm hangs on ‘scanning files to index’ background task
- How to redirect from a view to another view In Django
- Static media images are not displaying in Django
- How to delete a record in Django models?