How to initialize input form fields using URL parameters [django]

I can't set the input field values using the URL The form needs to be filled with data from the URL I tried initial= but it does not work. am I missing something

views.py
from django.shortcuts import render, redirect
from django.http import HttpResponse, request, response
from django.forms import formset_factory
from django.forms import inlineformset_factory
from .models import Participant, CheckingStatus
from .forms import BookForm, ParticipantFormSet

def form_view(request):
    if request.method == 'POST':
        form = BookForm(request.POST)
        formset = ParticipantFormSet(request.POST)
        if form.is_valid() and formset.is_valid():
            book = form.save()
            formset.instance = book
            formset.save()
    else:
        form = BookForm()
        initial_data = request.GET.copy()
        formset = ParticipantFormSet(initial=[initial_data])
        
    return render(request, 'form.html', {'form': form, 'formset': formset})
Back to Top