Есть модели загрузки содержимого:
class A_content(model.Model)
title = .........
@permalink
def get_absolute_url(self):
return ('django.views.generic.list_detail.object_detail', None, {'object_id': self.id})
class B_content(model.Model)
title = .........
@permalink
def get_absolute_url(self):
return ('django.views.generic.list_detail.object_detail', None, {'object_id': self.id})
class C_content(model.Model)
title = .......
@permalink
def get_absolute_url(self):
return ('django.views.generic.list_detail.object_detail', None, {'object_id': self.id})
#views.py
def search(request, model):
error = False
query = request.GET.get('q', '')
if query:
qset = (
Q(title__icontains=query)
)
results = model.objects.filter(qset).select_related().distinct()
#query = model.objects.all().select_related()
#results = model.objects.all().select_related()
else:
#results = []
return render_to_response('search.html', {'error' : True})
return render_to_response("search.html", {
"results": results,
"query": query
})
Теперь гвоздь программы:
#urls.py:
from django.views.generic.list_detail import object_list, object_detail
from MyApp.models import A_content, B_content, C_content
create_info_a = {'model': A_content}
display_info_a = {'queryset': A_content.objects.all()}
create_info_b = {'model': B_content}
display_info_b = {'queryset': B_content.objects.all()}
create_info_c = {'model': C_content}
display_info_c = {'queryset': C_content.objects.all()}
urlpatterns = patterns('',
url(r'^search/a_search/$', 'MyProj.MyApp.views.search',
{'model': A_content}),
url(r'^search/a_search/$', 'MyProj.MyApp.views.search',
{'model': B_content}),
url(r'^search/a_search/$', 'MyProj.MyApp.views.search',
{'model': С_content}),
url(r'^search/a_search/(?P<object_id>\d+)/$', object_detail,
display_info_a),
url(r'^search/b_search/(?P<object_id>\d+)/$', object_detail,
display_info_b),
url(r'^search/c_search/(?P<object_id>\d+)/$', object_detail,
display_info_c),
url(r'^search/c_search/(?P<object_id>\d+)/$', object_detail, display_info_c),
Я не могу понять, как исправить! Хочу посмотреть один объект, а выкидывает на другой.
Есть у кого соображения?
P.S. Извините, что такая простыня, но мало ли в коде налажал.