コード例 #1
0
ファイル: views.py プロジェクト: xiaoxiaolulu/xfz
def add_banner(request):
    form = AddBannerForm(request.POST)
    if form.is_valid():
        priority = form.cleaned_data.get('priority')
        image_url = form.cleaned_data.get('image_url')
        link_to = form.cleaned_data.get('link_to')
        banner = Banner.objects.create(priority=priority, image_url=image_url, link_to=link_to)
        return Response.response(data={'banner_id': banner.pk})
    else:
        return Response.response(message=form.get_errors())
コード例 #2
0
ファイル: views.py プロジェクト: cwj214228/Blog
def add_banner(request):
    form = AddBannerForm(request.POST)
    if form.is_valid():
        priority = form.cleaned_data.get('priority')
        image_url = form.cleaned_data.get('image_url')
        link_to = form.cleaned_data.get('link_to')
        banner = Banner.objects.create(priority=priority,
                                       image_url=image_url,
                                       link_to=link_to)
        return restful.result(data={"banner_id": banner.pk})
    else:
        return restful.params_error(form.get_errors())
コード例 #3
0
def add_banner(request):
    """添加轮播图"""
    form = AddBannerForm(request.POST)
    if form.is_valid():
        priority = form.cleaned_data.get("priority")
        image_url = form.cleaned_data.get("image_url")
        link_to = form.cleaned_data.get("link_to")
        banner = Banner.objects.create(priority=priority,
                                       image_url=image_url,
                                       link_to=link_to)
        return restful.result(data={"banner_id": banner.pk})
    else:
        return restful.params_error(message=form.get_errors())
コード例 #4
0
def abanner():
    form = AddBannerForm(request.form)
    if form.validate():
        name = form.name.data
        image_url = form.image_url.data
        link_url = form.link_url.data
        priority = form.priority.data
        banner = BannerModel(name=name, image_url=image_url, link_url=link_url, priority=priority)
        db.session.add(banner)
        db.session.commit()
        return restful.success()
    else:
        return restful.params_error(message=form.get_error())
コード例 #5
0
ファイル: views.py プロジェクト: zcboys/flask_bbs
def abanner():
    form = AddBannerForm(request.form)
    if form.validate():
        name = form.name.data
        image_url = form.image_url.data
        link_url = form.link_url.data
        priority = form.priority.data
        banner = BannerModel(name=name, image_url=image_url, link_url=link_url, priority=priority)
        db.session.add(banner)
        db.session.commit()
        return restful.success()
    else:
        return restful.params_error(message=form.get_errors())
コード例 #6
0
ファイル: views.py プロジェクト: liuqiao1995/dj_xtproj
def add_banners(request):
    form = AddBannerForm(request.POST)
    if form.is_valid():
        image_url = form.cleaned_data.get('image_url')
        link_to = form.cleaned_data.get('link_to')
        priority = form.cleaned_data.get('priority')
        banner = Banners.objects.create(image_url=image_url,
                                        link_to=link_to,
                                        priority=priority)
        # print('数据返回')
        return restful.result(data={'banner_id': banner.pk})
    else:
        # print(form.get_error())
        return restful.params_error(message=form.get_error())