def post(self, request): form = PublicityApplicationForm(request.POST, request.FILES) if not form.is_valid(): return render(request, 'campus_field/publicity/form.html', {'form': form}) app = form.save(commit=False) app.organization = request.user.organization app.save() return HttpResponseRedirect(reverse('publicity:manage'))
def post(self, request): app_id = request.GET.get('id') app = get_object_or_404(PublicityApplication, id=app_id) form = PublicityApplicationForm( request.POST, request.FILES, instance=app) if not form.is_valid(): return render(request, 'campus_field/publicity/form.html', {'form': form, 'app_id': app_id, 'post_url': \ reverse('publicity:modify')+'?id='+app_id}) form.save() return HttpResponseRedirect(reverse('publicity:manage'))
def get(self, request): app_id = request.GET.get('id') app = get_object_or_404(PublicityApplication, id=app_id) form = PublicityApplicationForm(instance=app) return render(request, 'campus_field/publicity/form.html', {'form': form, 'app_id': app_id, 'post_url': \ reverse('publicity:modify')+'?id='+app_id})
def get(self, request): return render(request, 'campus_field/publicity/form.html', {'form': PublicityApplicationForm()})