def create_batch(request, project_id, stage_id, template="create_project.html"): form = BatchForm(request.POST or None) if request.method == "POST" and form.is_valid(): new_project = form.save() print new_project return redirect("enterprise.project.stage", project_id=project_id) context = {"form": form, "title": _("Create Batch")} return render(request, template, context)
def post(self, request, *args, **kwargs): print request.POST if request.POST['etype'] == 'batch': form = BatchForm(request.POST) batch = form.save(commit=True) return HttpResponseRedirect('/admin/batch') if request.POST['etype'] == 'division': form = BatchDivisionForm(request.POST) div = form.save(commit=True) return HttpResponseRedirect('/admin/batch/#batch-div-add')
def post(self, request, *args, **kwargs): print request.POST if request.POST['etype']=='batch': form=BatchForm(request.POST) batch = form.save(commit=True) return HttpResponseRedirect('/admin/batch') if request.POST['etype']=='division': form=BatchDivisionForm(request.POST) div = form.save(commit=True) return HttpResponseRedirect('/admin/batch/#batch-div-add')
def post(self, request, *args, **kwargs): try: instance = Batch.objects.get(id=request.POST['bid']) form=BatchForm(request.POST,instance=instance) batch = form.save(commit=False) #user = User.objects.create_user(student.admission_no,student.email, 'johnpassword') #user.first_name=student.name #user.save() batch.save() msg="Record saved" except: msg="Unable to process, Please check all values are present" return HttpResponse(json.dumps(dict(result=msg)), content_type="application/json")
def post(self, request, *args, **kwargs): try: instance = Batch.objects.get(id=request.POST['bid']) form = BatchForm(request.POST, instance=instance) batch = form.save(commit=False) #user = User.objects.create_user(student.admission_no,student.email, 'johnpassword') #user.first_name=student.name #user.save() batch.save() msg = "Record saved" except: msg = "Unable to process, Please check all values are present" return HttpResponse(json.dumps(dict(result=msg)), content_type="application/json")
def get(self, request, *args, **kwargs): batch_form = BatchForm() div_form = BatchDivisionForm() print div_form return render(request, self.template_name, { 'batch_form': batch_form, 'div_form': div_form })
def get(self, request, *args, **kwargs): _batch_id = args[0] batchObj = Batch.objects.filter(id=_batch_id) batch = batchObj.values()[0] batch['bid'] = batchObj[0].id batch['start_date'] = batchObj[0].start_date.strftime('%d/%m/%y') batch['end_date'] = batchObj[0].end_date.strftime('%d/%m/%y') batch['etype'] = 'batch' form = BatchForm(batch) print form return render(request, self.template_name, {'form': form})