How to solve autocomplete error "NoReverseMatch at /"? I am making django project can anybody help me

model.py

class Mobile(models.Model):
mobile_id = models.AutoField
mobile_name = models.CharField(max_length=100)

views.py

def autosuggest(request):
print(request.GET)
query_original = request.GET.get('term')
queryset = Mobile.objects.filter(mobile_name__icontains=query_original)

mylist=[]
mylist += [x.mobile_name for x in queryset]
return JsonResponse(mylist,safe=False)

urls.py

path("autosuggest/", views.autosuggest, name="Autosuggest"),

basic.html

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>

$( function() {

$( "#search" ).autocomplete({
  source: '{% url 'autosuggest' %}'
});
} );
</script>

I am also doing

source: '{% url 'my_app_name:autosuggest' %}'

in basic.html and in urls.py

app_name = 'my_app_name'

but it is not work. I am trying to href and another code but not working it show me NoReverseMatch at /. Reverse for 'autosuggest' not found. 'autosuggest' is not a valid view function or pattern name.



Read more here: https://stackoverflow.com/questions/64954749/how-to-solve-autocomplete-error-noreversematch-at-i-am-making-django-projec

Content Attribution

This content was originally published by Nick Luv at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: