mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 21:40:13 +03:00
flake
This commit is contained in:
parent
672df63599
commit
a63b9fde2e
|
@ -1294,24 +1294,6 @@ class RecursiveField(Field):
|
||||||
next = RecursiveField(allow_null=True)
|
next = RecursiveField(allow_null=True)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Implementation notes
|
|
||||||
#
|
|
||||||
# Only use __getattribute__ to forward the bound methods. Stop short of
|
|
||||||
# forwarding all attributes for the following reasons:
|
|
||||||
# - if you forward the __class__ attribute then deepcopy will give you back
|
|
||||||
# the wrong class
|
|
||||||
# - if you forward the fields attribute then __repr__ will enter into an
|
|
||||||
# infinite recursion
|
|
||||||
# - who knows what other infinite recursions are possible
|
|
||||||
#
|
|
||||||
# We only forward bound methods, but there are some attributes that must be
|
|
||||||
# accessible on both the RecursiveField and the proxied serializer, namely:
|
|
||||||
# field_name, read_only, default, source_attrs, write_attrs, source. As far
|
|
||||||
# as I can tell, the cleanest way to make these fields availabe without
|
|
||||||
# piecemeal forwarding them through __getattribute__ is to call bind and
|
|
||||||
# __init__ on both the RecursiveField and the proxied field using the exact
|
|
||||||
# same arguments.
|
|
||||||
|
|
||||||
def __init__(self, to='self', to_module=None, **kwargs):
|
def __init__(self, to='self', to_module=None, **kwargs):
|
||||||
self.to = to
|
self.to = to
|
||||||
self.to_module = to_module
|
self.to_module = to_module
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
class LinkSerializer(serializers.Serializer):
|
class LinkSerializer(serializers.Serializer):
|
||||||
name = serializers.CharField(max_length=25)
|
name = serializers.CharField(max_length=25)
|
||||||
next = serializers.RecursiveField(required=False, allow_null=True)
|
next = serializers.RecursiveField(required=False, allow_null=True)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user