python - Django-easy-pjax 不能正常工作

标签 python django single-page-application pjax

我使用来自 django-easy-pjax . 我有这个基本代码:

ubase.html

 <script type="text/javascript" src="{% static "/static/js/jquery-1.9.1.min.js" %}"></script>
<script src="{% static "/static/js/jquery.pjax.js" %}"></script>
{% block side%}
        It is {% now "c" %} 

sdfdsfdsf
<a href="/uu/">uu</a>
<a href="/uu1/">uu1</a>
<br/><br/><br/><br/><br/><br/>

{%endblock side%}


{%block main%}

sdfdfsdfdsfdsfdfdsf
{%endblock main%}

entry_index.html

{% extends "ubase.html"|pjax:request %}
{%block main%}
1
{%endblock main%}

entry_index2.html

{% extends "ubase.html"|pjax:request %}
{%block main%}
2
{%endblock main%}

我的观点:

def entry_index1( request ):
    return render_to_response('entry_index1.html', {}, context_instance = RequestContext(request))

def entry_index( request ):
    return render_to_response('entry_index.html', {}, context_instance = RequestContext(request))

还有我的网址

url(r'^uu/$', search_views.entry_index),
url(r'^uu1/$', search_views.entry_index1),

但是当我使用点击 uu 链接或 uu1 链接时,时间会改变并且 pjax 不能正常工作 example .为什么会这样?

最佳答案

确保你有 django.core.context_processors.request 添加到 TEMPLATE_CONTEXT_PROCESSORS 和 pjax 模板来响应 PJAX 请求,在你的例子中是 pjax_ubase.html。看看模板标签的源代码:https://github.com/nigma/django-easy-pjax/blob/master/easy_pjax/templatetags/pjax_tags.py

关于python - Django-easy-pjax 不能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17075281/

相关文章:

python - 如何将具有缺失值的列转换为字符串?

python - 使用 pandas 和 matplotlib 绘制多条线图

python - 在 Python 中,deepcopy 和 [each[ :] for each in List] 有什么区别

python - 将列表中的每个值设置为前一个值的某种修改?

python - Django Keycloak 集成流程

oauth-2.0 - 在 OAuth 2.0 隐式流中验证​​ nonce 的位置?

javascript - 在 AngularJS 中使用指令时如何使表单无效

Django Memcached - 如何检查是否使用了 memcached?

python - Django CBV继承: Overriding attributes

javascript - ReactJS 服务器端渲染和 componentDidMount 方法