Django ManyToManyField getting Field ‘id’ expected a number but got b’x89PNGrn

I want to upload multiple files in Django. The code below getting Error Field 'id' expected a number but got b'x89PNGrn'. i want to use ManyToManyField as FileField. please i need the solution. I would be grateful for any help.

class FileModel(models.Model):
    filename = models.FileField(upload_to='files/')

class FileUploadModel(models.Model):
    file = models.ManyToManyField(FileModel)

class FileUploadingForm(forms.ModelForm):
    file = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True}), required=False)

    def __init__(self, *args, **kwargs):
        super(FileUploadingForm, self).__init__(*args, **kwargs)

    class Meta:
        model = FileUploadModel
        fields = ['file']

def uploading_view(request):
    if request.method == "POST":
        form = FileUploadingForm(request.POST, request.FILES)
        if form.is_valid():
            # post =
            for files in request.FILES.getlist("filename"):
                f = FileModel(filename=files)
            return HttpResponse('success')
        form = FileUploadingForm()
    return render(request, 'uploading.html', {'form': form})


<form action="." method="POST" enctype="multipart/form-data">

    {% csrf_token %}
    <button type="submit">Submit</button>



you can’t save data like this f = FileModel(filename=files)

try this

for files in request.FILES.getlist("filename"):
    f = FileModel.objects.create(filename=files)

Read this