27👍
Wow, I spent so much time on this problem!
The shortlist version would be:
<a href="#" id="projectname{{project.id}}" data-type="text" data-pk="{{project.id}}" data-title="Enter project name" data-url="{% url 'updateproject' project.id %}" data-params="{csrfmiddlewaretoken:'{{csrf_token}}'}">{{ project.name }}</a>
And then, call
$('#projectname{{project.id}}').editable();
- All the values of the many to many field : Django
- Create a post activate script in Conda
- Django 1.7 removing Add button from inline form
- Why is django's settings object a LazyObject?
2👍
I faced this in my PHP Project and I solved it by using the ajaxOptions option. Picked up the CSRF Token from the meta tag and added it to the request header.
ajaxOptions: {
dataType: 'json',
beforeSend: function(xhr){
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]')
.attr('content'));
}
}
- Store browser tab specific data
- Django Test Client post() returns 302 despite error on view's post()
- Indirect inline in Django admin
- Docker + Celery tells me not to run as root, but once I don't, I lack permissions to run
0👍
I think the correct one especially if you are working with rails to add
ajaxOptions: {
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
},
inside editable function to be
$('#projectname').editable({
showbuttons: 'bottom',
ajaxOptions: {
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
},
type: 'textarea',
url: '/url/url'
});
- Group models in django admin
- Problem launching docker-compose : python modules not installed
- How do you use Django-filter's '__in' lookup?
- Performance, load and stress testing in Django
- Use of python super function in django model
Source:stackexchange.com