I have a function in a view that I am using to upload CSV data and write to a DB. That part is working. However, when I try to check if there was data updated or created, I am getting an error which reads:

> 
> "*local variable 'created' referenced before assignment*".
> 
> 
> 

The function in the view is as follows

```
def bookings_upload(request):

    prompt = {
        'order': "Please import a valid CSV file"
    }
    if request.method == "GET":
        return render(request, 'booking_app/importBookings.html', prompt)

    csv_file = request.FILES['bookings']

    if not csv_file.name.endswith('.csv'):
        messages.error(request, "This file is not a .csv file.")
        return redirect('/booking_app/bookings_upload/') 

    data_set = csv_file.read().decode('utf-8')
    io_string = io.StringIO(data_set)
    next(io_string)

    for column in csv.reader(io_string, delimiter=',', quotechar="|"):
        _, created = Bookings.objects.update_or_create(
            book_date=column[0],
            grower_number=column[1],
            bales_booked=column[3],
            sale_date=column[6],
            book_id=column[11],
            reoffer=column[12]
        )
    ) 

    if created:
        messages.success(request, "Bookings have been imported successfully")
    else:
        messages.warning(request, "No new bookings were imported. Please check/verify your csv file")   

    context = {}
    return render(request, 'booking_app/importBookings.html', context)

```

What am I missing? Any assistance will be greatly appreciated.