Monday, 15 August 2011

Search form not working using class based view -



Search form not working using class based view -

i'm trying create search form it's not working. here codes:

class locationsearchmixin(object): def get_queryset(self): q = self.request.get.get('q') if q none: homecoming queryset class storelistview(locationsearchmixin, listview): model = store <form action="" method="get"> <input type="text" name="q" /> <button type="submit">search</button> </form>

there must add together in locationsearchmixin:

class locationsearchmixin(object): def get_queryset(self): queryset = super(locationsearchmixin, self).get_queryset() q = self.request.get.get('q') if q none: homecoming queryset homecoming queryset.filter(location__istartswith=q)

django-class-based-views

No comments:

Post a Comment