[Fixed]-Django, Role matching query does not exist

0👍

It is ok world I fixed the issue.
Because I had spaces in my roles and location the dropdowns were the issue so I changed them a bit

var data={}

$(document).ready(function() {
    $.get('/api/new/emp/', function(response){

        $('#employer').empty()

        $('#location').empty()

        $('#role').empty()


        $.each(response.Employers, function(){
            //$('#employer').append('<option value='+this+'>'+this+'</option>')
            $('#employer').append($('<option></option>').val(this).text(this))
    })

        $.each(response.Locations, function(){
            //$('#location').append('<option value='+this+'>'+this+'</option>')
            $('#location').append($('<option></option>').val(this).text(this))
    })

        $.each(response.Roles, function(){
            // $('#role').append('<option value='+this+'>'+this+'</option>')
            $('#role').append($('<option></option>').val(this).text(this))

I have left the old code in so you can see the fix

1👍

I think one of two things is happening. Possibility one: the values you’re posting for Role and Location don’t match the format you expect. For instance, the label in the dropdown may be the name or role_name but the posted value may be the ID. You mentioned that those data points are selected with a drop-down – double-check the value attributes in your options for that select to make sure they’re really names and not IDs.

Or, your jquery function is setting data['role_name'] and data['location'] before a selection is made (or is failing to change the value if the selection is changed).

If you post the value of data we can figure out which one is the case, but I’m almost certain it’s one of these two issues.

Leave a comment