我的测试网站没有显示所有文章...... [英] my test website does not show all the articles...

查看:121
本文介绍了我的测试网站没有显示所有文章......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上关注django教程(Mike Hibbert's),在tutuorial 4他完成了基本的文章应用程序,有一次他进入了扩展名为/ articles / all的网址,他的所有对象都出现了,当我尝试它时,只有第一个出现...当我尝试使用扩展名/ article / get /< 1,2,3>单独获得每个对象时,它的工作完美... ...



articles.html:

I was following a django tutorial online (Mike Hibbert's) and at tutuorial 4 he completed the basic articles app and at one point he goes to the url with the extension '/articles/all', all of his objects show up, wheres as when i try it, only the first one appears... its works perfectly when i try to get each object individually with the extension /article/get/<1, 2, 3>...

articles.html:

<html>
<body>
<h1> Articles </h1>
{% for article in articles %}
<div>
<h2><a href="/article.get/{{ article.id }}/">{{ article.title }}</a></h2>
<p>{{article.body}}</p>
</div>
{% endfor %}
</body>
</html>





article.html:





article.html:

<html>
<body>
<h1> {{ article.title }} </h1>
<p> {{article.body}} </p>
</body>
</html?









文章/ views.py:





articles/views.py:

def articles(request):
    return render_to_response('articles.html',
                              {'articles' : Article.objects.all() })
    
                               
                               
                              
def article(request, article_id=1):
    return render_to_response('article.html',
                              {'article' : Article.objects.get(id=article_id) }) 





articles / urls.py:



articles/urls.py:

urlpatterns = patterns('',
    url(r'^all/$', 'article.views.article'),
    url(r'^get/(?P<article_id>\d+)/$', 'article.views.article'),

推荐答案

',' article.views.article'),
url(r ' ^ get /(?P< article_id> \d +)/
', 'article.views.article'), url(r'^get/(?P<article_id>\d+)/


',' article.views.article'),


询问所有者((Mike Hibbert)。
Ask the owner ((Mike Hibbert).


这篇关于我的测试网站没有显示所有文章......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆