def person_new(request): if request.method == "POST": form = PersonForm(request.POST) if form.is_valid(): person = form.save(commit=False) person.save() return redirect("person_detail", pk=person.pk) else: form = PersonForm() return render(request, "blog/person_edit.html", {"form": form})
def person_edit(request, pk): person = get_object_or_404(Person, pk=pk) if request.method == "POST": form = PersonForm(request.POST, instance=person) if form.is_valid(): person = form.save(commit=False) print(person) person.first_name = request.POST["first_name"] person.last_name = request.POST["last_name"] person.gender = "M" person.save() return redirect("person_detail", pk=person.pk) else: form = PersonForm(instance=person) return render(request, "blog/person_edit.html", {"form": form})
def registration(request): return render_to_response('blog/login.html', {'form': PersonForm()})
def add_user(request): form = PersonForm() return render(request, 'blog/login.html', {'form': form})