from django.http import HttpResponseRedirect
from django.shortcuts import render

from .forms import TelForm, TelFormAttrs, TelFormNoInit, TwoTelForm


def home(request):
    if request.POST:
        form = TelForm(request.POST)
        return HttpResponseRedirect('{path}?ok'.format(path=request.path))
    else:
        form = TelForm()

    return render(request, 'home.html', {'form': form})


def attrs_test(request):
    form = TelFormAttrs()
    return render(request, 'home.html', {'form': form})


def initial_test(request):
    form = TelForm(initial={'tel_number': '+81123456789'})
    return render(request, 'home.html', {'form': form})


def two_fields_test(request):
    if request.POST:
        form = TwoTelForm(request.POST)
    else:
        form = TwoTelForm()
    return render(request, 'home.html', {'form': form})


def no_init_test(request):
    form = TelFormNoInit()
    return render(request, 'home.html', {'form': form})

from django.http import HttpResponseRedirect
from django.shortcuts import render

from .forms import TelForm, TelFormAttrs, TelFormNoInit, TwoTelForm


def home(request):
    if request.POST:
        form = TelForm(request.POST)
        return HttpResponseRedirect('{path}?ok'.format(path=request.path))
    else:
        form = TelForm()

    return render(request, 'home.html', {'form': form})


def attrs_test(request):
    form = TelFormAttrs()
    return render(request, 'home.html', {'form': form})


def initial_test(request):
    form = TelForm(initial={'tel_number': '+81123456789'})
    return render(request, 'home.html', {'form': form})


def two_fields_test(request):
    if request.POST:
        form = TwoTelForm(request.POST)
    else:
        form = TwoTelForm()
    return render(request, 'home.html', {'form': form})


def no_init_test(request):
    form = TelFormNoInit()
    return render(request, 'home.html', {'form': form})
