wd, The problem here is that when you're creating the context, the name 'result' is not defined. When the get_queryset() method returns, the result name goes out of scope. My guess that's why you're getting a NameError.
If that's not it, I would suggest cutting and pasting the traceback and showing us the actual code (with line numbers if you have them). It will help us diagnose the problem. -Jorge On Thu, Oct 17, 2019 at 7:25 PM wd <w...@wdicc.com> wrote: > oh ,sorry my mistake. But I think the error is pretty clear ... > > On Fri, Oct 18, 2019 at 10:23 AM wd <w...@wdicc.com> wrote: > >> Dude, you need to indent at the line include 'context' ... it's a >> beginners problem... >> >> On Fri, Oct 18, 2019 at 10:14 AM sotiris moustogiannis < >> sotom...@outlook.com> wrote: >> >>> I have an error: name 'result' is not defined >>> >>> >>> >>> def search(request): >>> >>> def get_queryset(self): >>> query = self.request.GET.get('q') >>> result = Shops.objects.filter(Q(city=query)) >>> >>> return result >>> >>> context={ >>> 'shops' : result, >>> } >>> >>> return render(request, 'booking/search.html',context) >>> >>> >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/543debc7-d517-4a7a-a9b8-f3fc7c7cc60d%40googlegroups.com >>> <https://groups.google.com/d/msgid/django-users/543debc7-d517-4a7a-a9b8-f3fc7c7cc60d%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CABexzmhZtCXQRWB7S%3DL8S3B2rzmnbi3Raan1MFKW1asbSoShqg%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CABexzmhZtCXQRWB7S%3DL8S3B2rzmnbi3Raan1MFKW1asbSoShqg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANfN%3DK_7-xzLEYw%3DR8-NF5De%3D7H79O%3D0NXUkk_u26ZmZm8-iZw%40mail.gmail.com.