can't override django Form widget attributes correctly

Viewed 78

I want to change the name of the widget but then i have two names inside the input

class DocumentForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        # to delete colon after field's name
        kwargs.setdefault('label_suffix', '')
        super(DocumentForm, self).__init__(*args, **kwargs)

    class Meta:
        model = Document
        name = "document"
        fields = ('id',
                  'comment',
                  'private',
                  'position',
                  'marked')
        # fields = '__all__'

    marked = forms.IntegerField(
        required=False,
        widget=forms.NumberInput(
            attrs={
                'name': "asdasdjasdasjdldsa",
                'id': "device_documents___name___marked",
                'class': 'check preview_image',
                'onchange': 'cbChange(this)',
                'mazen': "document_set-__name__-position"
            },
        )
    )

but if i print this i have two name name="marked" and name="asdasdjasdasjdldsa" how to delete the first one?

print(f["marked"])
<input type="number" name="marked" name="asdasdjasdasjdldsa" id="device_documents___name___marked" class="check preview_image" onchange="cbChange(this)" mazen="document_set-__name__-position">
0 Answers
Related