Silent failing of the fields definition

閲覧: 7 回
最初の未読メッセージにスキップ

Berthier Lemieux

未読、
2015/11/16 3:31:592015/11/16
To: Django REST framework
Hi,
   I noticed that if the definition of the fields of a serializer is erroneous (most commonly because of a typo), the DRF swallows the error and later call to is_valid() will always return true.
 
   Errors like these:
  
class ImageSerializer(serializers.ModelSerializer):
class Meta:
model = Feedback
fields = ('file') #Oops, this is not a tuple, but a string. It should be ('file',)

 
   Since the error is caught down below and not visible to the user of the serializer, figuring out what's going wrong is not trivial for someone not familiar with the inner workings of the framework. The framework would be (slightly) easier to use if the error would be visible. Would it be possible to add some debug trace or make sure the error is thrown when the bogus serializer is imported?

-Berthier

   

Xavier Ordoquy

未読、
2015/11/16 3:39:442015/11/16
To: django-res...@googlegroups.com
Unfortunately this is hard to catch mostly because strings themselves are iterables.

Regards,
Xavier,
Linovia.
signature.asc
全員に返信
投稿者に返信
転送
新着メール 0 件