mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-10-13 00:20:17 +08:00
Fix nullability of blank charfields in values and values_list (#1020)
Char fields with blank=True set should not be considered nullable in the context of values() and values_list() querysets. I'm also not a huge fan of the way these fields are made optional in the constructur to the model classes, it feels like it would be better to mark the arguments as having a default value, rather than allow sending in None, but I'd rather keep this fix small and look at the overall problem at a later point.
This commit is contained in:
1 parent
dd0fe02367
commit
1a29ad4f97
3 files changed
+37
No files matched your search
@@ -263,6 +263,9 @@ class DjangoContext:
|
||||
return attname
|
||||
|
||||
def get_field_nullability(self, field: Union[Field, ForeignObjectRel], method: Optional[str]) -> bool:
|
||||
if method in ("values", "values_list"):
|
||||
return field.null
|
||||
|
||||
nullable = field.null
|
||||
if not nullable and isinstance(field, CharField) and field.blank:
|
||||
return True
|
||||
|
||||
Reference in new issue
Block a user