mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
slug_url_kwarg should default to same as slug_field
This commit is contained in:
parent
9731b95fc3
commit
867033e676
|
@ -494,8 +494,8 @@ class HyperlinkedRelatedField(RelatedField):
|
|||
Represents a to-one relationship, using hyperlinking.
|
||||
"""
|
||||
pk_url_kwarg = 'pk'
|
||||
slug_url_kwarg = 'slug'
|
||||
slug_field = 'slug'
|
||||
slug_url_kwarg = None # Defaults to same as `slug_field`
|
||||
default_read_only = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -503,8 +503,8 @@ class HyperlinkedRelatedField(RelatedField):
|
|||
self.view_name = kwargs.pop('view_name')
|
||||
except:
|
||||
raise ValueError("Hyperlinked field requires 'view_name' kwarg")
|
||||
self.slug_url_kwarg = kwargs.pop('slug_url_kwarg', self.slug_url_kwarg)
|
||||
self.slug_field = kwargs.pop('slug_field', self.slug_field)
|
||||
self.slug_url_kwarg = kwargs.pop('slug_url_kwarg', self.slug_field)
|
||||
self.format = kwargs.pop('format', None)
|
||||
super(HyperlinkedRelatedField, self).__init__(*args, **kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user