Exemple #1
0
 def post(self, request):
     form = MagazineForm(request.POST, request.FILES)
     if not form.is_valid():
         return render(request, 'magazine/magazine-form.html',
                 {'form': form, 'post_url': reverse('magazine:add')})
     form.save()
     return HttpResponseRedirect(reverse('magazine:manage'))
Exemple #2
0
 def post(self, request):
     form = MagazineForm(request.POST, request.FILES)
     if not form.is_valid():
         return render(request, 'magazine/magazine-form.html',
                 {'form': form, 'post_url': reverse('magazine:add')})
     form.save()
     return HttpResponseRedirect(reverse('magazine:manage'))
Exemple #3
0
 def post(self, request):
     maga_id = request.GET.get('id')
     magazine = get_object_or_404(Magazine, id=maga_id)
     form = MagazineForm(request.POST, request.FILES, instance=magazine)
     # 用于检查期数是否有重复,但要排除自身与自身重复
     form.model_id = maga_id
     if not form.is_valid():
         return render(request, 'magazine/magazine-form.html',
                 {'form': form,
                  'post_url': reverse('magazine:modify') + '?id=' + maga_id})
     form.save()
     return HttpResponseRedirect(reverse('magazine:manage'))
Exemple #4
0
 def get(self, request):
     maga_id = request.GET.get('id')
     magazine = get_object_or_404(Magazine, id=maga_id)
     form = MagazineForm(instance=magazine)
     return render(request, 'magazine/magazine-form.html',
             {'form': form,
              'post_url': reverse('magazine:modify') + '?id=' + maga_id})
Exemple #5
0
 def post(self, request):
     maga_id = request.GET.get('id')
     magazine = get_object_or_404(Magazine, id=maga_id)
     form = MagazineForm(request.POST, request.FILES, instance=magazine)
     # 用于检查期数是否有重复,但要排除自身与自身重复
     form.model_id = maga_id
     if not form.is_valid():
         return render(request, 'magazine/magazine-form.html',
                 {'form': form,
                  'post_url': reverse('magazine:modify') + '?id=' + maga_id})
     form.save()
     return HttpResponseRedirect(reverse('magazine:manage'))
Exemple #6
0
 def get(self, request):
     form = MagazineForm()
     return render(request, 'magazine/magazine-form.html',
             {'form': form, 'post_url': reverse('magazine:add')})