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


Python shortcuts.render_to_response方法代碼示例

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


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

示例1: form_detail

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def form_detail(request, slug, template="forms/form_detail.html"):
    form = get_object_or_404(models.DocumentSetForm, slug=slug)
    request_context = RequestContext(request)
    args = (form, request_context, request.POST or None)

    form_for_form = forms.DocumentSetFormForForm(*args)

    if request.method == 'POST':
        if not form_for_form.is_valid():
            form_invalid.send(sender=request, form=form_for_form)
            return HttpResponseBadRequest(json.dumps(form_for_form.errors), content_type='application/json')
        else:
            entry = form_for_form.save()
            form_valid.send(sender=request, form=form_for_form, entry=entry, document_id=request.session['document_id_for_entry'])
            return HttpResponse('')
    return render_to_response(template, { 'form': form }, request_context) 
開發者ID:crowdata,項目名稱:crowdata,代碼行數:18,代碼來源:views.py

示例2: choose_current_organization

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def choose_current_organization(request):
    """ Show which Organizations can be selected """
    organizations = request.user.organization_set.all()
    
    current_organization = None
    
    try:
        user_profile = request.user.get_profile()      
    except models.UserProfile.DoesNotExist:
        user_profile = models.UserProfile(user=request.user, name=request.user.get_full_name())
        user_profile.save()
        
    if user_profile:
        current_organization = user_profile.current_organization

    template = 'choose_current_organization.html' if organizations.count() > 0 else 'without_organization.html'
    return render_to_response(template, {
                                'organizations': organizations, 
                                'current_organization': current_organization,
                                'organization_signup_link': settings.ORGANIZATION_SIGNUP_LINK
                               },
                               context_instance = RequestContext(request)) 
開發者ID:crowdata,項目名稱:crowdata,代碼行數:24,代碼來源:views.py

示例3: render_select_site_form

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def render_select_site_form(self, request, context, form_url=''):
        """
        Render the site choice form.
        """
        app_label = self.opts.app_label
        context.update({
            'has_change_permission': self.has_change_permission(request),
            'form_url': mark_safe(form_url),
            'opts': self.opts,
            'add': True,
            'save_on_top': self.save_on_top,
        })

        return render_to_response(self.select_site_form_template or [
            'admin/%s/%s/select_site_form.html' % (app_label, self.opts.object_name.lower()),
            'admin/%s/select_site_form.html' % app_label,
            'admin/usersettings/select_site_form.html',  # added default here
            'admin/select_site_form.html'
        ], context) 
開發者ID:mishbahr,項目名稱:django-usersettings2,代碼行數:21,代碼來源:admin.py

示例4: index

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def index(request):
    if request.method == 'POST':
        form = PathAnalysisForm(request.POST)
        if  form.is_valid():
            query = form.cleaned_data['search']
            print(query)
            #here is where the magic happens!
            #search in kegg
#            data = kegg_rest_request('list/pathway/hsa')
#            pathways = kegg_rest_request('find/pathway/%s' % (query))
            pathways = Pathway.objects.filter(Q(name__icontains=query))
            # print pathways
            
    else:
        form = PathAnalysisForm()
#        pathways = kegg_rest_request('list/pathway/hsa')
        pathways = Pathway.objects.all()    
    
    
    return render_to_response('pathway_analysis/index.html', {'form': form, 'pathways': pathways}, context_instance=RequestContext(request)) 
開發者ID:raonyguimaraes,項目名稱:mendelmd,代碼行數:22,代碼來源:views.py

示例5: index

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def index(request):
    offline_register(request)

    if request.user.is_authenticated():
        request.session['username'] = request.user.username
        request.session['uid'] = request.user.pk
    else:
        request.session['uid'] = -1

    print(">>>>>>>", request.session.get('newdump'));
    # if request.session.get('newdump'):
    #      dumpid = request.session.get('newdump')
    #  return render(request,'index.html',context={"dump":dumpid})
    return render_to_response("index.html", locals(), context_instance=RequestContext(request))
    # contex = {
    #     "request":RequestContext(request),
    #     "dump":dumpid
    # }
    # return render(request,'index.html',contex) 
開發者ID:virtualrealitysystems,項目名稱:aumfor,代碼行數:21,代碼來源:views.py

示例6: process_detail

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def process_detail(request):
    context = {}
    try:
        if request.POST.get("setPid") and request.POST.get("setDumpid"):

            context = {
                "pid": request.POST.get("setPid"),
                "dumpid": request.POST.get("setDumpid"),
                "dumpname": request.POST.get("dumpName")
            }
        else:
            raise Exception("No Process Id or Dump Id Specified")

    except Exception as ex:
        raise Exception(ex)
    return render_to_response("singleprocess.html", context, context_instance=RequestContext(request)) 
開發者ID:virtualrealitysystems,項目名稱:aumfor,代碼行數:18,代碼來源:views.py

示例7: detail

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def detail(self, request):
        
        '''
        查看用戶的ansible的option數據
        '''
        
        result = self._is_login(request)
        if result[0] :
            username = result[1]
        else :
            return HttpResponseRedirect(reverse('login'))
    
        vault_password = request.session['vault_password']
        result = self.ansible_option_api.detail(username, vault_password)
        if result[0] :
            data = result[1]
            error_message = ''
            self.logger.info(self.username + ' 查看用戶' + username + '的ansible配置成功')
        else :
            data = {}
            error_message = self.username + ' 查看用戶' + username + '的ansible配置失敗,查詢時發生錯誤,原因:' + result[1]
            self.logger.error(error_message) 
            error_message = result[1]
            
        return render_to_response('option_detail.html', {'data':data, 'login_user':username, 'error_message':error_message, 'nav_html':self.nav_html, 'lately_whereabouts':self.latelywhere_html}) 
開發者ID:lykops,項目名稱:lykops,代碼行數:27,代碼來源:options.py

示例8: generic_composition_view

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def generic_composition_view(request, search=None):
    data = {'search':search}
    composition = ''
    space = []
    if request.method == 'POST':
        p = request.POST
        search = p.get('search', '')
        data.update(p)
    if not search:
        return render_to_response('materials/generic_composition.html',
                data,
                RequestContext(request))
        
    gc = GenericComposition(search)
    data['gc'] = gc
    return render_to_response('materials/generic_composition.html', 
            data,
            RequestContext(request)) 
開發者ID:wolverton-research-group,項目名稱:qmpy,代碼行數:20,代碼來源:composition.py

示例9: journal_view

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def journal_view(request, journal_id):
    journal = Journal.objects.get(id=journal_id)
    dates = journal.references.values_list('year', flat=True)
    plt.hist(dates)
    plt.xlabel('Year')
    plt.ylabel('# of publications with new materials')
    img = StringIO.StringIO()
    plt.savefig(img, dpi=75, bbox_inches='tight')
    data_uri = 'data:image/jpg;base64,'
    data_uri += img.getvalue().encode('base64').replace('\n', '')
    plt.close()

    some_entries = Entry.objects.filter(reference__journal=journal)[:20]
    data = get_globals()
    data.update({'journal':journal, 
        'hist':data_uri,
        'entries':some_entries})
    return render_to_response('data/reference/journal.html', 
            data,
            RequestContext(request)) 
開發者ID:wolverton-research-group,項目名稱:qmpy,代碼行數:22,代碼來源:references.py

示例10: author_view

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def author_view(request, author_id):
    author = Author.objects.get(id=author_id)
    materials = Entry.objects.filter(reference__author_set=author)
    coauths = {}
    for co in Author.objects.filter(references__author_set=author):
        papers = Reference.objects.filter(author_set=author)
        papers = papers.filter(author_set=co)
        mats = Entry.objects.filter(reference__in=papers)
        data = {'papers': papers.distinct().count(),
                'materials': mats.distinct().count()}
        coauths[co] = data

    data = get_globals()
    data.update({'author':author,
        'materials':materials,
        'coauthors':coauths})
    return render_to_response('data/reference/author.html', 
            data,
            RequestContext(request)) 
開發者ID:wolverton-research-group,項目名稱:qmpy,代碼行數:21,代碼來源:references.py

示例11: search

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def search(request):
    d = RequestContext(request, {})
    return render_to_response("search.html", d) 
開發者ID:LibraryOfCongress,項目名稱:gazetteer,代碼行數:5,代碼來源:views.py

示例12: feature_detail

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def feature_detail(request, id):
    feature = get_object_or_404(Feature, pk=id)
    geojson = json.dumps(feature.get_geojson())
    d = RequestContext(request, {
        'feature': feature,
        'geojson': geojson
    })
    return render_to_response("feature.html", d) 
開發者ID:LibraryOfCongress,項目名稱:gazetteer,代碼行數:10,代碼來源:views.py

示例13: index

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def index(request):
    places_count = Place.objects.count("*")
    context = RequestContext(request, {
        'total_count': places_count
    })
    return render_to_response("index.html", context) 
開發者ID:LibraryOfCongress,項目名稱:gazetteer,代碼行數:8,代碼來源:views.py

示例14: edit_place

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def edit_place(request, place_id):
    place = get_place_or_404(place_id)
    geojson = json.dumps(place.to_geojson())
    context = RequestContext(request, {
        'place': place,
        'place_geojson': geojson
    })
    return render_to_response("edit_place.html", context) 
開發者ID:LibraryOfCongress,項目名稱:gazetteer,代碼行數:10,代碼來源:views.py

示例15: module_handler

# 需要導入模塊: from django import shortcuts [as 別名]
# 或者: from django.shortcuts import render_to_response [as 別名]
def module_handler(request):
    """
    Handle module request from UI. Response from this request builds
    UI Explorer tree
    """
    logger.debug("module_handler: enter")
    lst = []
    if request.user.is_authenticated():
        path = request.GET.get('node', '')
        deep = request.GET.get('deep', '')
        username = request.user.username
        if path == 'root':
            # Request for root models
            modules = ModuleAdmin.get_modulelist(username)
            modules.sort()
            for m in modules:
                lst.append(node_t.format(m.split('@')[0]))
        else:
            modules = [path.split('/')[0]]
            for module in modules:
                filename = ModuleAdmin.cxml_path(username, module)
                if filename is not None:
                    logger.debug("module_handler: loading " + filename)
                    module = cxml.get_cxml(filename)
                    nodes = module.get_lazy_subtree(path, deep)
                    lst.extend([ET.tostring(node) for node in annotate(nodes)])
                else:
                    logger.error("module_handler: %s not found !!" + module)

    logger.debug("module_handler: exit")
    return render_to_response('loader.xml', {'nodes': lst}, RequestContext(request)) 
開發者ID:CiscoDevNet,項目名稱:yang-explorer,代碼行數:33,代碼來源:views.py


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