views.py
python_backend/curriculum/django/blog/views.py
from django.shortcuts import render
from .models import Post
def post_list(request):
posts = Post.objects.all().order_by('-created_at')
return render(request, 'blog/post_list.html', {'posts': posts})
Articles liés
apps.py
apps.py — python source code from the python backend learning materials (python_backend/curriculum/django/blog/apps.py).
Lire l'article →0001_initial.py
0001_initial.py — python source code from the python backend learning materials (python_backend/curriculum/django/blog/migrations/0001_initial.py).
Lire l'article →models.py
models.py — python source code from the python backend learning materials (python_backend/curriculum/django/blog/models.py).
Lire l'article →urls.py
urls.py — python source code from the python backend learning materials (python_backend/curriculum/django/blog/urls.py).
Lire l'article →manage.py
manage.py — python source code from the python backend learning materials (python_backend/curriculum/django/manage.py).
Lire l'article →asgi.py
asgi.py — python source code from the python backend learning materials (python_backend/curriculum/django/myproject/asgi.py).
Lire l'article →