cheers again for the response. However the code i used to get the
wrapper working is given below
def searchwrap(request):
error = False
if 'q' in request.GET:
q = request.GET['q']
if not q:
error = True
else:
articles = 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,
Mymodel.objects.filter(status=1),
'pub_date',
template_name = 'search_form.html',
extra_context = {
'error': error,
}
)
great!
So, in order to get a (very simple) search box on each page in a
default blog app with url which goes like /year/month/day/slug/ i
wrapped archive_index, archive_year, archive_month, archive_day and
object_detail from django.views.generic import date_based with a
function that picks up the from GET. This is obviously a very thick
way of achieving this. In the interests of elegant code could i pass
the relevant generic function view name to my wrapper? I tried this by
just including a parameter in the call for the wrapper view but it
didn't work, i thought something like this would suffice, but no:
(r'^$',views.searchwrap(generic.view)),
am i way off?
Cheers,
On Apr 20, 5:50 am, Anatoliy <
Anatoliy.La...@gmail.com> wrote:
> 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,
> }
> )
>