Python Django Tutorial 4(a) – How to Set the home or default page

1. Create a view that returns the rendered home page

def home(request):
	html = "<html><body><h1>Welcome Home!</h1></body></html>"
	return HttpResponse(html)

2. Modify the urls.py to add the redirect for the home page

from article.views import home
urlpatterns = [
    url(r'^$', home, name='home'),
]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s