9. Get some title and date in that page in django


Just change

view.py

from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
import datetime

#def hello_page(request):
 #   return HttpResponse("BTMS")


def hello_page(request):
    now = datetime.datetime.now()
    html = "<html> <body bgcolor='lightgrey'><h1><center><font color=red>BTMS</font></center></h1><hr><h3>welcome to my home page and  the current date and time is %s </h3></body</html>" %now
    return HttpResponse(html)



and url.py is same as early

url.py
from django.conf.urls import patterns, include, url
from login.views import hello_page
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'btms.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', hello_page),


)


o/p
====


 

No comments:

Post a Comment