Merge changement Emile

This commit is contained in:
unknown 2015-08-17 00:32:01 -04:00
commit e0b0dfdfcc
3 changed files with 20 additions and 3 deletions

View File

@ -0,0 +1,7 @@
{% extends 'template.html' %}
{% block content %}
<section>
<h1>{{ article.title }}</h1>
</section>
{% endblock %}

View File

@ -3,4 +3,5 @@ from blog import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^(?P<article_id>\d+)$', views.show, name='show'),
)

View File

@ -1,6 +1,15 @@
from django.shortcuts import render
from blog.models import *
from django.http import Http404
from blog.models import Article
def index(request):
articles = Article.objects.all
return render(request, 'blog/index.html', {'articles':articles})
articles = Article.objects.order_by('-created_at')
return render(request, 'blog/index.html', {'articles': articles})
def show(request, article_id):
try:
article = Article.objects.get(id=article_id)
return render(request, 'blog/show.html', {'article': article})
except Article.DoesNotExist:
raise Http404("Article does not exist")