def post(self, request): form = BasicForm(request.POST) if not form.is_valid(): ctx = {'form': form} return render(request, 'form/form.html', ctx) # save data return redirect('/form/success')
def post(self, request): form = BasicForm(request.POST) if not form.is_valid(): ctx = {'form': form} return render(request, 'form/form.html', ctx) # If there are no errors, we would save the data x = reverse('form:success') return redirect(x)
def post(self, request): form = BasicForm(request.POST) if not form.is_valid(): ctx = {'form': form} return render(request, 'form/form.html', ctx) # Save the Data # Look up the url for the next view in urls.py x = reverse('form:success') return redirect(x)
def post(self, request) : form = BasicForm(request.POST) if not form.is_valid() : ctx = {'form' : form} return render(request, 'form.html', ctx) js = json.dumps(request.POST, sort_keys=True, indent=4) ctx = {'title': 'request.POST', 'dump': js} return render(request, 'formdump.html', ctx)
def get(self, request): old_data = { 'title': 'SakaiCar', 'mileage': 42, 'purchase_date': '2018-08-14' } form = BasicForm(initial=old_data) ctx = {'form': form} return render(request, 'form.html', ctx)
def get(self, request): old_data = { 'title': "Vitz", 'mileage' : 240, 'purchase_date': '2020-07-23' } form = BasicForm(initial=old_data) ctx = {'form': form} return render(request, 'form/form.html', ctx)
def get(self, request): old_data = { 'title': "Suzukicar", 'mileage' : 24, 'purchase_date': '2018-08-24' } form = BasicForm(old_data) ctx = {'form': form} return render(request, 'form/form.html', ctx)
def get(self, request): form = BasicForm() ctx = {'form': form} return render(request, 'form.html', ctx)
def example(request): form = BasicForm() return HttpResponse(form.as_table())