mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-02-02 01:44:40 +00:00
Add initial search app
This commit is contained in:
parent
eef7bf2e17
commit
0117ec7014
0
pyi2phosts/search/__init__.py
Normal file
0
pyi2phosts/search/__init__.py
Normal file
5
pyi2phosts/search/urls.py
Normal file
5
pyi2phosts/search/urls.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.conf.urls.defaults import *
|
||||
|
||||
urlpatterns = patterns('pyi2phosts.search.views',
|
||||
(r'^$', 'search'),
|
||||
)
|
21
pyi2phosts/search/views.py
Normal file
21
pyi2phosts/search/views.py
Normal file
@ -0,0 +1,21 @@
|
||||
from django.db.models import Q
|
||||
from django.views.generic import list_detail
|
||||
|
||||
import settings
|
||||
from pyi2phosts.postkey.models import i2phost
|
||||
|
||||
|
||||
def search(request):
|
||||
q = request.GET.get('q', '')
|
||||
fil = Q(name__icontains=q)
|
||||
qs = i2phost.objects.filter(fil)
|
||||
return list_detail.object_list(
|
||||
request = request,
|
||||
queryset = qs,
|
||||
template_name = 'search_results.html',
|
||||
template_object_name = 'host',
|
||||
paginate_by = 40,
|
||||
extra_context = {
|
||||
'title': settings.SITE_NAME,
|
||||
}
|
||||
)
|
@ -62,6 +62,7 @@ urlpatterns = patterns('',
|
||||
url(r'^faq/$', object_list, extsources, name='faq'),
|
||||
url(r'^browse/$', object_list, browse_hosts, name='browse'),
|
||||
url(r'^latest/$', object_list, latest_hosts, name='latest'),
|
||||
(r'^search/$', include('pyi2phosts.search.urls')),
|
||||
(r'^postkey/', include('pyi2phosts.postkey.urls')),
|
||||
(r'^jump/', include('pyi2phosts.jump.urls')),
|
||||
# Example:
|
||||
|
Loading…
x
Reference in New Issue
Block a user