[Answer]-Modified django form cleand_data do is not renedered in data

1👍

If I understood you have been attempts uses the clean method. If I right, you did it a little wrong. Try use def clean() with a form’s field:

forms.py

class AccountNameField(forms.CharField):

    def clean(self, value):
        value = u'SVC' + value
        return value


class NewADServiceAccount(forms.Form):

    Account_Name = AccountNameField(min_length=3, max_length=21, required=True,
                                    #initial="Please write desired name of "
                                    #+ "this service account.",
                                    help_text="Please write the desired name "
                                    + "of this account. The prefix 'SVC_' will"
                                    + " be added to this name",)

views.py

form = NewADServiceAccount(request.POST or None)
if form.is_valid():
   ...

prefix is used only into a forms. If I am not mistaken prefix would be assign each fields of the form as prefix-namefield

Leave a comment