Commit 055986b5 by Tom Christie

More helpful exception when URL cannot reverse and field value was empty. Closes #2698.

parent c4f908d4
......@@ -282,6 +282,13 @@ class HyperlinkedRelatedField(RelatedField):
'model in your API, or incorrectly configured the '
'`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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment