예제 #1
0
파일: views.py 프로젝트: ajaycode/django1
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})
예제 #2
0
파일: views.py 프로젝트: ajaycode/django1
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})
예제 #3
0
def registration(request):
        return render_to_response('blog/login.html', {'form': PersonForm()})
예제 #4
0
def add_user(request):
    form = PersonForm()
    return render(request, 'blog/login.html', {'form': form})