Hey so I have this list of campaigns that have a button to start and stop the process.

'''

```
from django.shortcuts import render
from .models import Campaign
from .forms import CampaignForm, CampaignStatusFormSet

def home_view(request):
    queryset = Campaign.objects.all()

    if request.method == 'POST':
        form_type = request.POST.get('id')
        if form_type == 'campaign_status':
            formset = CampaignStatusFormSet(
                request.POST, request.FILES,
                queryset=queryset,
            )
            for form in formset.forms:
                if form.is_valid():
                    form.save()
    else:
        formset = CampaignStatusFormSet(queryset=queryset)

    campaigns_and_forms = list(zip(queryset, formset))

    context = {
        'formset': formset,
        'campaigns_and_forms': campaigns_and_forms,
    }

    return render(request, 'campaigns_in_progress.html', context)

```

'''

But when I run it and click on the button to change play/pause it shows this error.

**UnboundLocalError: local variable 'formset' referenced before assignment**

Can anyone help me refactor this code so that it doesn't show this error?