If you are looking for a text / char field and do not want it to remove spaces, you can set strip = False in the form constructor method, and then use the form in the admin panel.
class YourForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(YourForm, self).__init__(*args, **kwargs) self.fields['myfield'].strip = False class Meta: model = YourModel fields = "__all__"
Then you can use this form in the admin form=YourForm specifying form=YourForm in the admin.py file.
source share