mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
Added detailed warning about duplicate keys
This commit is contained in:
parent
7d1c1b4649
commit
f9dd11df72
|
@ -15,6 +15,7 @@ import copy
|
|||
import datetime
|
||||
import inspect
|
||||
import types
|
||||
import warnings
|
||||
from decimal import Decimal
|
||||
from django.core.paginator import Page
|
||||
from django.db import models
|
||||
|
@ -298,7 +299,9 @@ class BaseSerializer(WritableField):
|
|||
for name, value in list(self.fields.items()):
|
||||
key = self.get_field_key(name)
|
||||
if key in ret:
|
||||
raise Warning()
|
||||
warnings.warn("Duplicate key found in fields. This can happen if `get_field_key`"
|
||||
" can return the same string for two different inputs! Ensure your keys are unique"
|
||||
" after running them all through `get_field_key`", Warning, stacklevel=3)
|
||||
ret[key] = name
|
||||
return ret
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user