Mario Menezes
unread,Apr 25, 2012, 12:49:51 PM4/25/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-...@googlegroups.com
Hi,
I've created a custom search form with some additional processing for empty results but no matter what I do, this form is being sillently ignored when processing.
I could not figure out the problem, so please, help me with this.
My urls.py:
urlpatterns += patterns('haystack.views',
url(r'^busca$', MyFacetedSearchView(form_class=FacetedSearchForm , searchqueryset=sqs, template='lfs/search/search.html'), name='haystack_search_marca'),
url(r'^busca$', search_view_factory(view_class=SearchView, template='lfs/search/search.html',\
form_class=ProductSearchForm, \
), name='haystack_search'),
)
My form:
class ProductSearchForm(SearchForm):
def search(self):
sqs = super(ProductSearchForm, self).search()
print "AH AH AH AH AH \n\n\n"
if not self.is_valid():
return self.no_query_found()
if not self.cleaned_data.get('q'):
return self.no_query_found()
sqs = self.searchqueryset.auto_query(self.cleaned_data['q'])
if len(sqs)==0:
q_split = q.split()
if len(q_split)>3:
q1 = ' '.join(q_split[0:2])
sqs_alt = self.searchqueryset.filter(content=q1)
if len(sqs_alt)>0:
if self.load_all:
sqs_alt = sqs_alt.load_all()
sqs = sqs_alt
if self.load_all:
sqs = sqs.load_all()
return sqs
I've put a print statement so make sure my form is being called and nothing is printed by django!
If I put the print statement directly on haystack forms.py, it got printed.
Is there any other thing I have to do so that my form is called? Any error that's preventing it of being processed?
Thanks in advance for any help.
Mario Menezes