Please create sample forms based on the following views: from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required
from django.contrib import messages

from .models import Resident, School, Billing, Municipality
from .forms import ResidentForm, SchoolForm, BillingForm

def homepage(request):
    return render(request, 'homepage.html')

@login_required
def resident_detail(request, resident_id):
    resident = get_object_or_404(Resident, pk=resident_id)
    return render(request, 'resident_detail.html', {'resident': resident})

@login_required
def resident_edit(request, resident_id):
    resident = get_object_or_404(Resident, pk=resident_id)

    if request.method == "POST":
        form = ResidentForm(request.POST, instance=resident)
        if form.is_valid():
            resident = form.save(commit=False)
            resident.save()
            messages.success(request, 'Resident details updated successfully!')
            return redirect('resident_detail', resident_id=resident.id)
    else:
        form = ResidentForm(instance=resident)

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

@login_required
def school_list(request):
    schools = School.objects.all()
    return render(request, 'school_list.html', {'schools': schools})

@login_required
def school_detail(request, school_id):
    school = get_object_or_404(School, pk=school_id)
    return render(request, 'school_detail.html', {'school': school})

@login_required
def school_edit(request, school_id):
    school = get_object_or_404(School, pk=school_id)

    if request.method == "POST":
        form = SchoolForm(request.POST, instance=school)
        if form.is_valid():
            school = form.save(commit=False)
            school.save()
            messages.success(request, 'School details updated successfully!')
            return redirect('school_detail', school_id=school.id)
    else:
        form = SchoolForm(instance=school)

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

@login_required
def billing_list(request):
    bills = Billing.objects.all()
    return render(request, 'billing_list.html', {'bills': bills})

@login_required
def billing_detail(request, bill_id):
    bill = get_object_or_404(Billing, pk=bill_id)
    return render(request, 'billing_detail.html', {'bill': bill})

@login_required
def billing_edit(request, bill_id):
    bill = get_object_or_404(Billing, pk=bill_id)

    if request.method == "POST":
        form = BillingForm(request.POST, instance=bill)
        if form.is_valid():
            bill = form.save(commit=False)
            bill.save()
            messages.success(request, 'Billing details updated successfully!')
            return redirect('billing_detail', bill_id=bill.id)
    else:
        form = BillingForm(instance=bill)

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

@login_required
def municipality_list(request):
    municipalities = Municipality.objects.all()
    return render(request, 'municipality_list.html', {'municipalities': municipalities})