Django - How use generic views from a Django external App in my own App?

I'm new to Django...

I have installed a Django external App called Haystack, this external App have a "" file inside "python2.6/site-packages/haystack". I think this "" is called a "generic view" in Django terms.

This generic view is called using "" like this:

urlpatterns = patterns('haystack.views', 
                   url(r'^search/$', FacetedSearchView(form_class=FacetedSearchForm, searchqueryset=sqs), name='haystack_search'), 

I need to make the jump from this generic views to my App. My question goes in the direction of How Can I Do This?

The code of Haystack "" goes like this:

from django.conf import settings
from django.core.paginator import Paginator, InvalidPage
from django.http import Http404
from django.shortcuts import render_to_response
from django.template import RequestContext
from haystack.forms import ModelSearchForm, FacetedSearchForm
from haystack.query import EmptySearchQuerySet


class SearchView(object):

    def __init__(self, template=None, load_all=True, form_class=None, searchqueryset=None, context_class=RequestContext, results_per_page=None):

    def __call__(self, request):

    def build_form(self, form_kwargs=None):

    def get_query(self):

    def get_results(self):

    def build_page(self):

    def extra_context(self):

    def create_response(self):

def search_view_factory(view_class=SearchView, *args, **kwargs):

class FacetedSearchView(SearchView):

    def __init__(self, *args, **kwargs):

    def build_form(self, form_kwargs=None):

    def extra_context(self):

def basic_search(request, template='search/search.html', load_all=True, form_class=ModelSearchForm, searchqueryset=None, context_class=RequestContext, extra_context=None, results_per_page=None):

Can someone give what steps I should follow to take out the code from the "" and put the thing working in my "" App?

Best Regards,


Try to put (r'^search/', include('haystack.urls')),. You also might want to read "Getting started with Haystack"


#your root
from django.conf.urls.defaults import *
from haystack.forms import FacetedSearchForm
from haystack.query import SearchQuerySet
from haystack.views import FacetedSearchView

sqs = SearchQuerySet().filter(author='john')

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

BTW, it's all in the docs.

Did you follow all the steps in the docs?

Use the extra_context method to add or overwrite the other variables in the context.

Need Your Help

need some php function to remove slashes

php strip

My original string look like this .

Does it make sense to set up mediaPlayer to run in a separate thread in Android?

android multithreading media-player

I've recently begun experimenting with a mediaPlayer instance in my Android app. I implemented a couple different beeps for feedback to the user. Now, when I implemented an audioTrack (for a comp...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.