Giter VIP home page Giter VIP logo

django-ajax-search's People

Contributors

shxkm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

django-ajax-search's Issues

Search results that are forms - handling csrf tokens

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 %}


{% csrf_token %}

        <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 %}


Search for a competency in the box above.

{% endif %}`

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!

Fenced code block in article missing a line of code

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.