﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36171	When saving an object(null=True, blank=True) with an empty string __str__ in the admin page.	Antoliny		"When a field that allows blank and null is used as `__str__`, an issue occurs when saving the object in the admin page if the value is empty.

**TestCase**

{{{
class Comment(models.Model):
    author = models.CharField(max_length=128, null=True, blank=True)
    content = models.CharField(max_length=128)

    def __str__(self):
        return self.author
}}}
[[Image(save_error.png)]]
When clicking the save-related button, the following error is returned.
[[Image(error.png)]]
Everytime an object is saved in the admin page, a `LogEntry` is also created. It seems that an issue occurs when `LogEntry` tries to use the object's `__str__`.

My guess is that the `to_python` method in the `CharField(Form)` performs a `strip()` process, causing the value entered in the admin page to be ''         ""instead of """". As a result, it is treated as `None`, and an issue occurs when `LogEntry` tries to use `__str__` on that value."	Bug	new	contrib.admin	5.1	Normal		blank, str		Unreviewed	0	0	0	0	0	0
