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 render
post = [
{
'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 path
from . import views
urlpatterns = [
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.
No comments:
Post a Comment