Confused about using formset_factory

I try to delevop a CMS with django. It is necessery to add to each article a responsibilty maxtrix for each user.

settings.py:

RESPONSIBILITY_CHOICES = {
    "H": "Hauptverantwortlich",
    "N": "Nebenverantwortlich",
    "X": "Mitarbeit",
    "-": "Nichts",
}
class UserResponsibilityModel(models.Model):
    def get_user_responsibility():
        return {i: i for i in settings.RESPONSIBILITY_CHOICES}

    responsibility = models.CharField(max_length=5,choices=get_user_responsibility)
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    content_id = models.ForeignKey(ContentModel, on_delete=models.CASCADE)


    def __str__(self):
        return self.user.username

class UserResponsibleForm(forms.ModelForm):
    def get_user_responsibility():
        return {i: i for i in settings.RESPONSIBILITY_CHOICES}

    responsibility = forms.ChoiceField(choices=get_user_responsibility())


    class Meta:
        model = UserResponsibilityModel
        fields = ['user','responsibility','content_id']

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['user'].disabled = False
        self.fields['user'].widget = forms.TextInput(attrs={'readonly': 'readonly'})

        self.fields['user'].queryset = User.objects.all()
        if self.instance and self.instance.pk:
           self.fields['user'].initial = self.instance.username
        self.fields['user'].label = 'Username'
        self.fields['user'].help_text = None
        self.fields['content_id'].queryset=ContentModel.objects.all()

my template to Create the responsibiliies template:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Formset</title>

</head>
<body>
<form method="post" enctype="multipart/form-data">
    {% csrf_token %}
    {{ formset.management_form }}
        <table>
                {% for hidden in form.hidden_fields %}
                     {{ hidden }}
                 {% endfor %}
            {% for form in formset %}
            <tr>
                <td>{{ form.user.label_tag }}</td>
                <td>{{ form.user }}</td>
                <td>{{ form.responsibility }}</td>
                <td>{{ form.content_id }}</td>
            </tr>
            {% endfor %}
        </table>
    <input type="submit" value="Submit">
</form>

</body>
</html>

If I want to save the model I get to following error messages:

  <option value="3">Gregor Stanek</option>

</select>
    
      <input type="hidden" name="form-1-id" id="id_form-1-id">
    
</div><ul class="errorlist nonfield"><li>(Hidden field id) This field is required.</li></ul>


  <div>
    <label for="id_form-2-user">Username:</label>


<ul class="errorlist"><li>Select a valid choice. That choice is not one of the available choices.</li></ul>
<input type="text" name="form-2-user" value="cstanek" readonly="readonly" aria-invalid="true" id="id_form-2-user">

I dont find the error .
Thanks in Advance for the help

Side Note: When posting code, templates, errors, and other preformatted text here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.
(I’ve taken the liberty of correcting your original post.)

What does your view look like that is creating these forms and rendering that template?

Thank You for correcting the post i’m sorry about this:

Here is my view

def create(request):
    UserResponsibleFormSet = modelformset_factory(UserResponsibilityModel,form=UserResponsibleForm,extra=0)

    if request.method == 'POST':
        print(request.POST)
        formset = UserResponsibleFormSet(request.POST)
        print(formset)
        if formset.is_valid():
            formset.save()
            return HttpResponse("Erledigt!!!!")
    else:
        formset = UserResponsibleFormSet(queryset=User.objects.all())
    return render(request,'formset.html',{'formset':formset})

Aren’t you confused with modelform_factory?

One of the issues here is that you’re creating the model formset class based upon the UserResponsibilityModel, but you’re creating the instance of the formset from a query based on User:

but:

With the way that the models are defined, the primary key for a User will not necessarily need to match the pk of the UserResponsibilityModel

I’d change the queryset to be a query based on the UserResponsibilityModel and see where that gets you. (It may still not be right, but this is the first thing I see that isn’t.)