Hello,
Please try:
context = {
'posts': post
}
'Delvin Alexander' via Django users <django-users@googlegroups.com> schrieb am Mi., 2. Feb. 2022, 06:59:
Hello everyone,I am currently following a django tutorial regarding applications. I have followed through completely but for some reason, when I run server, i incur no errors but the web page is blank. Why would this be?Here is what is not displayed:from my Home.html file:--<!DOCTYPE html><html><head><title></title></head><body>{% for post in posts %}<h1>{{ post.title }}</h1><p>By {{ post.author }} on {{ post.date_posted}}</p><p>{{ post.content }}</p>{% endfor %}</body></html>from my views.py file:from django.shortcuts import renderpost = [{'author': 'CoreyMS','title': 'Blog Post','content': 'First Post Content','date_posted': 'August 27, 2018'},{'author': 'Jane Doe','title': 'Blog Post 2','content': 'Second Post Content','date_posted': 'August 28, 2018'}]def home(request):context = {'post': post}return render(request, 'blog/home.html', context)def about(request):return render(request, 'blog/about.html')
My urls.py:from django.urls import pathfrom . import viewsurlpatterns = [path('', views.home, name='blog-home'),path('about/', views.about, name='blog-about'),]
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e9b557a6-403b-46ce-bc18-8d19b0091f2an%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKGT9mzFaC4Eq9B_76nb0N2%2BRW-%2BNkbLMdfJT0Vph2qWuGefOw%40mail.gmail.com.
No comments:
Post a Comment