Klafyvel
6 years ago
16 changed files with 254 additions and 10 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,9 @@ |
|||
{% extends 'base.html' %} |
|||
|
|||
{% block content %} |
|||
<h3>Liste des articles</h3> |
|||
{% for article in articles %} |
|||
<h4><a href="{% url 'blog:article' article.pk %}">{{article.title}}</a></h4> |
|||
<p>Article écrit le {{article.date}}</p> |
|||
{% endfor %} |
|||
{% endblock %} |
@ -0,0 +1,9 @@ |
|||
{% extends 'base.html' %} |
|||
|
|||
{% block content %} |
|||
<h2>{{article.title}}</h2> |
|||
Publié le {{article.date}}. |
|||
<br/> |
|||
<br/> |
|||
{{article.text}} |
|||
{% endblock %} |
@ -1,14 +1,12 @@ |
|||
from django.shortcuts import render |
|||
from django.shortcuts import render, get_object_or_404 |
|||
from django.http import HttpResponse |
|||
|
|||
from .models import Article |
|||
|
|||
def index(request): |
|||
articles = Article.objects.order_by('-date') |
|||
s = ("Bonjour et bienvenue" |
|||
" sur mon super site trop cool" |
|||
"\nMes articles :" |
|||
) |
|||
for a in articles: |
|||
s += a.title + "\n" |
|||
return HttpResponse(s) |
|||
return render(request, 'blog/list_articles.html', {'articles':articles}) |
|||
|
|||
def view_article(request, pk): |
|||
article = get_object_or_404(Article, pk=pk) |
|||
return render(request, 'blog/view_article.html', {'article':article}) |
|||
|
Binary file not shown.
@ -0,0 +1,12 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<title>Mon super blog</title> |
|||
<meta charset="utf-8"/> |
|||
</head> |
|||
<body> |
|||
<h1>Mon super titre qu'on verra partout</h1> |
|||
<a href="{% url 'blog:index' %}">Retour à l'accueil</a> |
|||
{% block content %}{% endblock %} |
|||
</body> |
|||
</html> |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 24 KiB |
Loading…
Reference in new issue