Exemplo n.º 1
0
 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')
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 def get(self, request):
     form = BasicForm()
     ctx = {'form': form}
     return render(request, 'form.html', ctx)
Exemplo n.º 9
0
def example(request):
    form = BasicForm()
    return HttpResponse(form.as_table())