def add_img_video(request):
if request.method == 'POST':
adsUserForm = AdsUserForm(request.POST)
adsImgForm = AdsImgForm(request.POST, request.FILES)
if adsUserForm.is_valid() and adsImgForm.is_valid():
user = adsUserForm.save(commit=False)
user.adsNo = gernate_random_num()
user.type = u'视频'
adsUserForm.save()
img = adsImgForm.save(commit=False)
img.user1 = user
img.save()
return HttpResponseRedirect(reverse('adsInfo'))
return HttpResponseRedirect(reverse('ads2'))
else:
adsUserForm = AdsUserForm()
adsImgForm = AdsImgForm()
params = {
'user':adsUserForm,
'item':adsImgForm,
}
return render_to_response('ads.add2.html', params)
def edit_ads_item
django如何实现文件的上传,修改,删除,展示(03)
最新推荐文章于 2024-06-22 06:53:59 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)