mirror of
https://github.com/ConjureETS/site-2015.git
synced 2026-03-24 04:21:23 +00:00
Merge changement Emile
This commit is contained in:
commit
e0b0dfdfcc
7
blog/templates/blog/show.html
Normal file
7
blog/templates/blog/show.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{% extends 'template.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section>
|
||||||
|
<h1>{{ article.title }}</h1>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
@ -3,4 +3,5 @@ from blog import views
|
|||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^$', views.index, name='index'),
|
url(r'^$', views.index, name='index'),
|
||||||
|
url(r'^(?P<article_id>\d+)$', views.show, name='show'),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,6 +1,15 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from blog.models import *
|
from django.http import Http404
|
||||||
|
from blog.models import Article
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
articles = Article.objects.all
|
articles = Article.objects.order_by('-created_at')
|
||||||
return render(request, 'blog/index.html', {'articles':articles})
|
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")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user