Search code examples
djangodjango-haystackurl-pattern

django-haystack urlpatterns include('haystack.urls') where does it lead to?


I've recently begun to learn/install django/haystack/solr.

Following the tutorial given in haystack site,

I have urlpatterns = pattern('', r'^search/', include('haystack.urls'))

I found haystack installed in /usr/local/lib/python2.6/dist-packages/haystack and located urls.py there.

It has

urlpatterns=patterns('haystack.views', url(r'^$', SearchView(), name='haystack_search'),)

I thought the second argument of url() should be callable object.
I looked at the views.py and SearchView is a class.
What is going on here?
What's get called eventually?


Solution

  • Doesn't exactly answer your question, but a class can be a callable:

    >>> class Foo(object):
    ...     def __call__(self):
    ...             print "Called me"
    ... 
    >>> 
    >>> foo = Foo()
    >>> foo()
    Called me