slug_url_kwarg should default to same as slug_field

This commit is contained in:
Tom Christie 2012-11-05 16:43:44 +00:00
parent 9731b95fc3
commit 867033e676

View File

@ -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)