mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
More helpful exception when URL cannot reverse and field value was empty. Closes #2698.
This commit is contained in:
parent
c4f908d4ee
commit
055986b5b0
|
@ -282,6 +282,13 @@ class HyperlinkedRelatedField(RelatedField):
|
||||||
'model in your API, or incorrectly configured the '
|
'model in your API, or incorrectly configured the '
|
||||||
'`lookup_field` attribute on this field.'
|
'`lookup_field` attribute on this field.'
|
||||||
)
|
)
|
||||||
|
if value in ('', None):
|
||||||
|
value_string = {'': 'the empty string', None: 'None'}[value]
|
||||||
|
msg += (
|
||||||
|
" WARNING: The value of the field on the model instance "
|
||||||
|
"was %s, which may be why it didn't match any "
|
||||||
|
"entries in your URL conf." % value_string
|
||||||
|
)
|
||||||
raise ImproperlyConfigured(msg % self.view_name)
|
raise ImproperlyConfigured(msg % self.view_name)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user