0

So I am trying to pass a query in views.py which is working just fine in python shell. I am facing problem in my django project.

views.py:

def result(request):            # Shows the matched result
    query = request.GET.get('inc_search')
    check = Incubators.objects.filter(incubator_name__icontains= query).exclude(verify = False)
    return render(request, 'main/results.html', {'incubators': incubators,'check': check})

def details(request, incubator_id):
    inc = get_object_or_404(Incubators, pk = incubator_id)
    details = Details.objects.get(pk = incubator_id)
    return render(request, 'main/details.html', {'inc': inc, 'details': details})


def locate(request, incubator_id):
    pos = Incubators.objects.values_list('latt', 'lonn').filter(pk = incubator_id)
    return render(request, 'main/locate.html', {'pos': pos})

My urls.py is below:

url(r'location/', views.location, name = 'location'),
url(r'prediction/', views.prediction, name = 'prediction'),
url(r'locate/', views.locate, name = 'locate'),

I am getting the following traceback:

TypeError at /locate/

locate() missing 1 required positional argument: 'incubator_id'

Request Method:     GET
Request URL:    http://127.0.0.1:8000/locate/
Django Version:     1.11.3
Exception Type:     TypeError
Exception Value:    

locate() missing 1 required positional argument: 'incubator_id'

Can anyone help me find the error?

Arjun Kashyap
  • 623
  • 2
  • 10
  • 24

1 Answers1

3

change your url from this

url(r'locate/', views.locate, name = 'locate'),

to

url(r'locate/(?P<incubator_id>\d+)/$', views.locate, name = 'locate'),
Exprator
  • 26,992
  • 6
  • 47
  • 59