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())
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())
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())
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())
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())
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())