[英]Django + elpaginaton + ajax, didnt work detailview class
Simply my DetailView wont open new pages with enabled 只是我的DetailView不会启用已打开的新页面
{% load el_pagination_tags %}
{%load el_pagination_tags%}
{% lazy_paginate base_publications %}
{%lazy_paginate base_publications%}
But, if i disable those tags everything works fine(except endless pagination ofc). 但是,如果我禁用这些标签,一切都将正常工作(无尽的分页ofc)。
Here an example: 这里是一个例子:
views.py views.py
class IndexPublication(AjaxListView):
context_object_name = 'base_publications'
template_name = 'Post/base.html'
page_template='Post/base_list.html'
def get_queryset(self, **kwargs):
if self.request.method == 'GET':
return Post_model.objects.order_by('-published_date')
class PublicationDetail(DetailView):
model = Post_model
template_name = 'Post/post_detail.html'
Base_list.html Base_list.html
{% load el_pagination_tags %}
{% lazy_paginate base_publications %}
<ul class="grid-container">
{% for post in base_publications %}
<li>
<a class="navbar" href="{% url 'publications:detail_publication' pk=post.id %}">
<h3 class="title">{{ post.preview_title|linebreaks }}</h3>
<p class="text">{{ post.preview_text|safe }}</p>
</a>
<img class='preview'src='{{ MEDIA_URL }}{{ post.preview_photo }}'>
{{ post.published_date }}
</li>
{% endfor %}
</ul>
Post_detail.html Post_detail.html
{% extends 'Post/base.html' %}
{% block content %}
<div class="post">
{{ object.main_title }}
{{ object.main_textbox|safe }}
{% if object.published_date %}
<div class="date">
{{ object.published_date }}
</div>
{% endif %}
</div>
{% endblock %}
With el_pagination ive got an error if i try to click on my url. 如果我尝试点击我的网址,则使用el_pagination ive会出现错误。
VariableDoesNotExist at /post/15/
Failed lookup for key [base_publications] in [{'True': True, 'False': False, 'None': None}, {}, {}, {'object': <Post_model: #БагажЗнаний КАК НЕ БОЯТЬСЯ ЛЕТАТЬ НА САМОЛЕТАХ>, 'post_model': <Post_model: #БагажЗнаний КАК НЕ БОЯТЬСЯ ЛЕТАТЬ НА САМОЛЕТАХ>, 'view': <Post.views.PublicationDetail object at 0x05146B50>}]
Request Method: GET
Request URL: http://192.168.1.2:8080/post/15/
**Django Version: 2.1.3**
Exception Type: VariableDoesNotExist
Exception Value:
Failed lookup for key [base_publications] in [{'True': True, 'False': False, 'None': None}, {}, {}, {'object': <Post_model: blabla, 'post_model': <Post_model: blbla>, 'view': <Post.views.PublicationDetail object at 0x05146B50>}]
Exception Location: C:\Users\poker king\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\base.py in _resolve_lookup, line 850
Python Executable: C:\Users\poker king\AppData\Local\Programs\Python\Python36-32\python.exe
**Python Version: 3.6.7**
**Error during template rendering**
In template C:\seniortravel\Post\templates\Post\base_list.html, error at line 3
Failed lookup for key [%s] in %r
1 {% load el_pagination_tags %}
2
3 {% lazy_paginate base_publications %}
I`m kinda new for this. 我有点新。 And give up on googling this problem.
并放弃谷歌搜索这个问题。 Thx for your assistance.
谢谢您的协助。
问题出在base.html中-我使用{%include%},但是在base_list中更改为{extends base.html}之后,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.