mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #10414 -- Made select_related() fail on invalid field names.
This commit is contained in:
committed by
Tim Graham
parent
b27db97b23
commit
3daa9d60be
@@ -681,6 +681,24 @@ lookups::
|
||||
...
|
||||
ValueError: Cannot query "<Book: Django>": Must be "Author" instance.
|
||||
|
||||
``select_related()`` now checks given fields
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``select_related()`` now validates that the given fields actually exist.
|
||||
Previously, nonexistent fields were silently ignored. Now, an error is raised::
|
||||
|
||||
>>> book = Book.objects.select_related('nonexistent_field')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
FieldError: Invalid field name(s) given in select_related: 'nonexistent_field'
|
||||
|
||||
The validation also makes sure that the given field is relational::
|
||||
|
||||
>>> book = Book.objects.select_related('name')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
FieldError: Non-relational field given in select_related: 'name'
|
||||
|
||||
Default ``EmailField.max_length`` increased to 254
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user