示例#1
0
    def post(self, request):
        form = HouseForm(request.POST)
        if not form.is_valid():
            ctx = {'form': form}
            return render(request, self.template, ctx)

        house = form.save()
        return redirect(self.success_url)
示例#2
0
    def post(self, request, pk):
        house = get_object_or_404(self.model, pk=pk)
        form = HouseForm(request.POST, instance=house)
        if not form.is_valid():
            ctx = {'form': form}
            return render(request, self.template, ctx)

        form.save()
        return redirect(self.success_url)
示例#3
0
 def get(self, request, pk):
     house = get_object_or_404(self.model, pk=pk)
     form = HouseForm(instance=house)
     ctx = {'house': house}
     return render(request, self.template, ctx)
示例#4
0
 def get(self, request):
     form = HouseForm()
     ctx = {'form': form}
     return render(request, self.template, ctx)
示例#5
0
    def get(self, request, pk):
        house = get_object_or_404(self.model, pk=pk)
        form = HouseForm(instance=house)
        context = {'form': form}

        return render(request, self.template, context)