#26557 closed Bug (fixed)
GenericIPAddressField no longer normalises empty values to None
Reported by: | Joshua Phillips | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The GenericIPAddressField
is documented to convert empty strings to None
when saving models and when filtering and updating: "If you allow for blank values, you have to allow for null values since blank values are stored as null."
#24092 broke this:
- return value or None + return connection.ops.value_to_db_ipaddress(value)
+ def value_to_db_ipaddress(self, value): + """ + Transforms a string representation of an IP address into the expected + type for the backend driver. + """ + return value
The default value_to_db_ipaddress
function doesn't convert empty strings to None, like the code it replaced did. This is particularly important when using a ModelForm
, since forms.GenericIPAddressField
sets the model's field to an empty string if the field is not provided.
Change History (7)
comment:1 by , 8 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
PR