Hi all,
So I am trying to display the current time and date, and I suppose I am doing something right, because I don’t get any errors. The problem is… I don’t see what I want to see.
I have already searched for a solution, but nothing that I tried works.
Here’s my views.py
from django.shortcuts import render
import datetime
# Create your views here.
def index(request):
# new view
return render(request, 'index.html')
# current time and date
terazData = datetime.datetime.now()
# passing the current date to the template
return render(request, 'index.html',{
'data': terazData,
})
and here’s my index.html
{% extends 'base.html' %}
{% load staticfiles %}
<!doctype html>
<html>
<head>
<title>Strona Domowa - {{block.super}}</title>
<link rel="stylesheet" href="{% static 'css/style.css' %}" />
</head>
<body>
{% block content %}
<h1>Hello World!</h1>
<p>I am a basic website.</p>
{{ data|date:"D d M Y" }}
{% endblock content %}
</body>
</html>