def add_twitt(request): form = TwittForm() if request.method == "POST": form = TwittForm(request.POST) if form.is_valid(): form.save() return redirect("home") return render_to_response("add_twitt.html", {"form": form}, RequestContext(request))
def edit_twitt(request, pk): twitt = get_object_or_404(Twitt, pk=pk) form = TwittForm(instance=twitt) if request.method == "POST": form = TwittForm(request.POST, instance=twitt) if form.is_valid(): form.save() return redirect("home") return render_to_response("add_twitt.html", {"form": form}, RequestContext(request))