Try this: return date_based.archive_index( request, Mymodel.objects.filter(status=1), 'date_field': 'pub_date', template_name = 'search_form.html', extra_context = { 'error': error, } )
On 20 апр, 02:01, SoCow <vivid.des...@gmail.com> wrote: > ok, i'm getting there. i figured out that i need to wrap the generic > view in my own function. To make the problem clear i'm trying to get a > simple search to live in the base.html template of a blog which uses > the date_based generic view. My wrapper function consists of: > > def searchwrap(request): > error = False > if 'q' in request.GET: > q = request.GET['q'] > if not q: > error = True > else: > set= Mymodel.objects.filter(title__icontains=q) > return django.views.generic.date_based.archive_index( > request, > queryset = set, > template_name = 'search_results.html', > extra_context = {'set': set} > ) > > return date_based.archive_index( > request, > template_name = 'search_form.html', > extra_context = { > 'error': error, > 'queryset': Mymodel.objects.filter(status=1), > 'date_field': 'pub_date' > } > ) > > I'm now getting the error: > > archive_index() takes at least 3 non-keyword arguments (1 given) > > i thought that i was passing it 3 non-keyword arguments, no? > > anyone any experience with this? > > Thanks > > On 19 Apr, 19:02, SoCow <vivid.des...@gmail.com> wrote: > > > Hi all, > > thanks for reading. > > > I've implemented search for my site following the example in > > thehttp://www.djangobook.com/en/2.0/chapter07/. My search view receives > > the search term from a GET event. > > > I want to use this same method in a generic view, but don't know how > > Any ideas? > > > Many thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---