How do you use views in Django? 


Views will take request to return response.  Let’s write a view in Django :  “example” using template example.html , using  the date-time module to tell us exact time of reloading the page.  Let’s edit a file called, and it will be inside randomsite/randomapp/

To do this save and copy following into a file:

from datatime import datetime
      from django.shortcuts import render
     def home (request):
return render(request, ‘Guru99_home.html’, {‘right_now’: datetime.utcnow()})

You have to determine the  VIEW first, and then uncomment this line located in file

# url ( r ‘^$’ , ‘randomsite.randomapp.views.home’ , name ‘example’),

This will reload the site making changes obvious.


© 2017