2015年3月1日日曜日

djangoでViewを作る

Viewとは

web上で見える部分の定義

やること


  • __init__.pyとかがあるディレクトリ内でviews.pyを作成
  • 同じディレクトリ内のurls.pyの修正
  • views.pyにwebで表示したいものを書く

urls.pyの修正


# url(r'^$', 'Karuta.views.home', name='home'),

url(r'^$', 'Karuta.views.home', name='home'),
コメントアウトを解除

views.pyにwebで表示したいものを書く


例:hello worldの出力
import django.shortcuts

def home(name):
    return django.shortcuts.HttpResponse('hello world')


あとは、python3 ./manage.py runserverを行って、ブラウザでhttp://127.0.0.1:8000を開くと、hello worldが表示される

1 件のコメント:

  1. Betting on the favourite might seem like an obvious technique to comply with, with the sportsbooks supplying you with a clear possibility on who’s extra more likely to|prone to} win. Some sports have big favorites in comparison with} others, corresponding to tennis, boxing and basketball. One of the best ideas to understand, value betting involves analyzing all the odds a sure sportsbook has for a market, and judging as as to whether they’re good value or not. All of one of the best betting sites on this piece could have a variety of|quite a lot of|a big selection of} ways in you will be able to|which 클레오카지노 you'll} deposit funds into your account, with the method for these typically being comparatively simple and straightforward to know. For instance, {you can|you'll be able to|you presumably can} combine the moneyline wager of the Giants, Jets and Yankees, and get a better payout than should you put three single wagers on all three teams to win the moneyline.

    返信削除