Пример #1
0
def edit_bio(request, username):
    person = get_object_or_404(DjangoPerson, user__username=username)
    if request.method == "POST":
        form = BioForm(request.POST)
        if form.is_valid():
            person.bio = form.cleaned_data["bio"]
            person.save()
            return HttpResponseRedirect("/%s/" % username)
    else:
        form = BioForm(initial={"bio": person.bio})
    return render(request, "edit_bio.html", {"form": form})
Пример #2
0
def edit_bio(request, username):
    person = get_object_or_404(DjangoPerson, user__username = username)
    if request.method == 'POST':
        form = BioForm(request.POST)
        if form.is_valid():
            person.bio = form.cleaned_data['bio']
            person.save()
            return redirect(reverse('user_profile', args=[username]))
    else:
        form = BioForm(initial = {'bio': person.bio})
    return render(request, 'edit_bio.html', {
        'form': form,
    })