我有很多应用程序,但我想在我的主页上生成所有应用程序的数据。这是我的应用程序:博客,成员
我想在我的主页上显示博客和我的成员 我知道如果我想生成一个应用程序的数据,我可以这样做: 博客/网址.py地址:
urlpatterns = [
url(r'^$', ListView.as_view(
queryset=Post.objects.all().order_by("-date")[:10],
template_name='blog1.html')),
在blog1.html中:
{% extends "index.html" %}
{% block blog %}
{% for post in blog_post %}
<div id="blog-wrapper" class="bgrid-third s-bgrid-half mob-bgrid-whole group">
<article class="bgrid">
<h5>{{ post.date }} </h5>
<h3><a href="/{{ post.id }}"><div class = "entry-title">{{ post.title }}</div></a></h3>
<p>{{ post.user }}</p>
<p><div class = "post_body">{{ post.body|safe|linebreaks }}</div></p>
</article>
</div>
{% endfor %}
{% endblock %}
{% block member %}
在这里,当我转到url时,我可以看到我写的所有博客,但是现在我想在一个页面上看到博客和成员(另一个应用程序),那么我该怎么做呢?你知道吗
然后在my blog1.html中:
我建议您使用^{} 的^{} 方法。你知道吗
在项目的
views.py
中创建视图:然后,更改
urls.py
:现在可以使用
posts
变量访问post,使用members
变量访问成员。你知道吗相关问题 更多 >
编程相关推荐