开启代码之旅 Launch With Code


1148 浏览 5 years, 4 months

3 First View using a Function Based View

版权声明: 转载请注明出处 http://www.codingsoho.com/

基本的view功能包括

  • 创建url
  • 创建view

在url.py添加新的url

urlpatterns = patterns('',
    # Examples:
    url(r'^$', lwc.views.home', name='home'),
)

创建views.py

from django.shortcuts import render
def home():
    context = {}
    template = "home.html"
    return render(request, template, context)