Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Closed
Description
Checklist
- I have verified that that issue exists against the
masterbranch of Django REST framework. - I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- This is not a usage question. (Those should be directed to thediscussion group instead.)
- This cannot be dealt with as a third party library. (We prefer new functionality to bein the form of third party libraries where possible.)
- I have reduced the issue to the simplest possible case.
- I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Steps to reproduce
- Create a
ModelSerializerincluding a field inMetawith a custom name (that isn't on the model). - Set the source of the field, in
extra_kwargsto a named field within the model. - Initialise the Serializer.
Expected behavior
- Creates a Serializer with a field with a custom field name, that has it's source as the specified field on the Model.
Actual behavior
TypeError: hasattr(): attribute name must be string
Caused by#5138 when accounting for*-sourced fields.
| source=extra_field_kwargs.get('source','*')!='*'orfield_name |
In the case thatsource is specified AND is not'*',extra_field_kwargs.get('source', '*') != '*' evaluates toTrue, and thussource = True,
leading to theTypeError
Pull Request with test that fails on master, and fix:#5388
Metadata
Metadata
Assignees
Labels
No labels