django-admin startproject timedate
.cd timedate
.python manage.py runserver
.
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path("datetime/",views.datetimee,name="datetime"),
]
timedate/timedate/view.py
, and add the below contents to it.
from django.shortcuts import HttpResponse
from datetime import datetime
def datetimee(request):
now = datetime.now()
return HttpResponse(f"current datetime is {now}")
python manage.py runserver
command and follow the localhost link.http://localhost:8000/datetime/
, if you are running local host on port 8000