當前位置: 首頁>>代碼示例>>Python>>正文


Python Request.user方法代碼示例

本文整理匯總了Python中models.Request.user方法的典型用法代碼示例。如果您正苦於以下問題:Python Request.user方法的具體用法?Python Request.user怎麽用?Python Request.user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Request的用法示例。


在下文中一共展示了Request.user方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: home

# 需要導入模塊: from models import Request [as 別名]
# 或者: from models.Request import user [as 別名]
def home(request):
    if request.method == 'POST':
            song_req = Request()
            song_req.user = request.POST.get('user', '')
            song_req.song = request.POST.get('song', '')
            song_req.message = request.POST.get('message', '')
            song_req.save()
    else:
        req = get_latest_request()
        listeners = get_listeners()
        title = get_title()
        return render_to_response('home.html', {'latest':req, 'listeners':listeners, 'title':title})
開發者ID:aocppy,項目名稱:housefm-radio,代碼行數:14,代碼來源:views.py

示例2: process

# 需要導入模塊: from models import Request [as 別名]
# 或者: from models.Request import user [as 別名]
def process(request):
    if request.method == 'POST':
        form = UploadedFileForm(request.POST, request.FILES)
        if form.is_valid():
            motive = form.cleaned_data["motive"]
            instances_used = form.cleaned_data["instance_num"]
            seed_content = request.FILES['file'].read()


            fetcher = Fetcher("fetch_queue", instances_used)
            instances_ids = fetcher.fetch(seed_content)

            #Could not parse directly from form because of the file
            req_model = Request()
            req_model.motive = motive
            req_model.instances_used = instances_used
            req_model.user = request.user
            req_model.content = seed_content
            req_model.instances_ids = json.dumps(instances_ids)
            req_model.save()

            return HttpResponseRedirect("/process/%d" % req_model.id)
開發者ID:maximilianom,項目名稱:fetcher,代碼行數:24,代碼來源:views.py


注:本文中的models.Request.user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。