shxkm / django-ajax-search Goto Github PK
View Code? Open in Web Editor NEWsource code for my tutorial implementing as-you-type/incremental search
Home Page: https://openfolder.sh/django-tutorial-as-you-type-search-with-ajax
source code for my tutorial implementing as-you-type/incremental search
Home Page: https://openfolder.sh/django-tutorial-as-you-type-search-with-ajax
Hello there,
I've used this method that allows a user to search for a competency to add to their profile. Each competency has 2 additional attributes, proficiency level and priority that the user may modify before adding.
`{% if competency_results %}
{% for competency in competency_results %}
<div class="col-md-1">
<input class="border-0 px-3 py-0 bg-transparent text-info" type="submit" value="+ADD">
</div>
<div class="col-md-5">
{{ competency.name }}
</div>
<div class="col-md-3">
<select name="priority">
<option value="1" selected>1 - Core</option>
<option value="2">2 - Secondary</option>
<option value="3">3 - Supplementary</option>
</select>
</div>
<div class="col-md-3">
<select name="proficiency">
{% for proficiency in proficiencies %}
<option value="{{ proficiency.pk}}">{{ proficiency }}</option>
{% endfor %}
</select>
</div>
<input type="hidden" name="roleid" value="{% with rolecms.all|first as rolecm %}{{ rolecm.roleref.id }}{% endwith %}">
<input type="hidden" name="compid" value="{{ competency.id }}">
<input type="hidden" name="typeid" value="1">
</div>
</form>
{% endfor %}
{% else %}
However, the csrf tokens are not being rendered in the dynamic results and so throw a 403 error: CSRF verification failed. Request aborted.
I'm really new to software development (python, django, and ajax) so I'm having trouble figuring out how to resolve this issue.
Thank you!
Hi! Firstly, thanks for this tutorial, it helped me a lot.
I think I found a small omission in the article:
Under the title "Making the view respond to Ajax requests", when the artists_view
is defined, there is a comment # ...earlier code
, and after that comment the following line of code is missing (I found it in the repository):
does_req_accept_json = request.accepts("application/json")
I hope this is useful.
Thanks again
Kind regards,
Martin
PS: I am trying to use this approach for doing autocomplete of the input (instead of updating an html element). If you have an article that covers that, or any suggestions I would appreciate it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.