I m New to Django...
我已安装了一个称为Haystack的Django外部应用系统,该外部应用在“python2.6/site- Packages/haystack”内有“view.py”。 我认为,“观点.py”在Django语中被称为“遗传观点”。
采用“urls.py”这样的通用观点:
urlpatterns = patterns( haystack.views ,
url(r ^search/$ , FacetedSearchView(form_class=FacetedSearchForm, searchqueryset=sqs), name= haystack_search ),
)
我需要从这种一般性观点跳跃到我的应用。 我的问题是,我如何能够做到这一点?
Haystack“views.py”守则就是这样:
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
RESULTS_PER_PAGE = getattr(settings, HAYSTACK_SEARCH_RESULTS_PER_PAGE , 20)
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):
...
难道有人会给我采取什么步骤,从“urls.py”中删除该守则,并把事情放在我的“观点......py”应用中?
Best Regards,