当前位置: 首页>>代码示例>>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;未经允许,请勿转载。