eldarion-ajax | a library for adding declarative ajax functionality
kandi X-RAY | eldarion-ajax Summary
kandi X-RAY | eldarion-ajax Summary
This is a plugin that Eldarion uses for all of its AJAX work. No more writing the same 20 line $.ajax blocks of Javascript over and over again for each snippet of AJAX that you want to support. Easily extend support on the server side code for this by adding a top-level attribute to the JSON you are already returning called "html" that is the rendered content. Unlike a backbone.js approach to building a web app, eldarion-ajax leverages server side template rendering engines to render and return HTML fragments. This project used to be called bootstrap-ajax but the connection with Twitter Bootstrap was tenuous at best so we thought it best to rename to eldarion-ajax.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of eldarion-ajax
eldarion-ajax Key Features
eldarion-ajax Examples and Code Snippets
Community Discussions
Trending Discussions on eldarion-ajax
QUESTION
Django 2.2.1
When I use Pinax Likes(https://github.com/pinax/pinax-likes), there is a 405 error.
The steps are as follows:
pip3 install pinax-likes
Added
'pinax.likes',
to the project's settings.py file, then added:
ANSWER
Answered 2019-May-29 at 14:18I don't see how pinax-likes widget can actually work with the current code. It's broken. I see you opened an issue, if someone is still actively maintaining it they might fix it. Or you could fix it and propose a pull request.
There are two problems with the {% likes_widget %}
:
It cannot work without ajax, because it's just an link, i.e. it will send a GET request to your view. But the view expects a POST request, which is logical, since liking makes a change to the database and so it should be a POST. Therefore, without ajax, the view throws a 405 error.
It uses eldarion-ajax to make the ajax POST request, but since again it's just a
a.click
event, it won't post any data, i.e. it doesn't post the CSRF token. The view won't allow the missing token (it doesn't have the @csrf_exempt decorator), so it throws a 403 error.
Now the only way I see around this is to write your own HTML and/or ajax and not use the likes_widget.
You can wrap the like button in a form and replace the like button with a
that submits the form (instead of an
tag). This way, you can include the
{% csrf_token %}
tag in the form and the post will work. This will refresh the page.You can write your own ajax call to handle a click on the like button and post to the same view and include the csrftoken in the data posted.
This is fairly simple to implement, you can use the existing pinax like view, so it's only a change in your HTML template.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install eldarion-ajax
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page