Commit 113e6c9e authored by Daniel W Bond's avatar Daniel W Bond

added new listingsearchform to searchform in site-wide urls

parent 2c49520c
......@@ -10,6 +10,7 @@ from django.contrib.auth.decorators import login_required
from haystack.views import SearchView
# imports from your apps
from .views import HomepageView, ChartsView
from trades.forms import ListingSearchForm
admin.autodiscover()
......@@ -26,7 +27,8 @@ urlpatterns = patterns('',
url(r'^mod/', include('mod.urls')),
# search
url(r'^search/', login_required(SearchView(), login_url='login'), name='search'),
url(r'^search/', login_required(SearchView(form_class=ListingSearchForm),
login_url='login'), name='search'),
# site-wide pages
# homepage is weird for cacheing... no special url, but different content
......
# core django imports
from django import forms
from django.utils.translation import ugettext_lazy as _
# third party imports
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Button, Submit, Layout, Fieldset, HTML, Field
from crispy_forms.bootstrap import AppendedPrependedText, FormActions
from haystack.forms import SearchForm
# imports from your apps
from .models import Listing, Bid, Flag, BidFlag, Rating
......@@ -239,3 +241,10 @@ class RatingForm(forms.ModelForm):
class Meta:
model = Rating
# overwrites the search form to include bootstrap css classes and autofocus
class ListingSearchForm(SearchForm):
q = forms.CharField(required=False, label=_('Search'),
widget=forms.TextInput(attrs={'type': 'search', # default
'class': 'form-control', # bootstrap
'autofocus': 'autofocus'})) # field already selected
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment