Closed sonnyhu closed 10 years ago
@SonnyHu Let me have a look at it and I'll let you know if it would fit later tonight. Thanks!
@estebistec Thanks! If you think it would be fit, I will go ahead wrap my code up.
Thinking on this some more, wouldn't you be relying on some integration with models using that field? On it's own, it wouldn't help you with that field, right?
I agree with you. But it will depend on model only when it is used, the field itself will not depend on model.
output = PartialDictField(included_keys=['key1', 'key2'])
, then key1 and key2 will be in that model's field, but PartialDictField only need to iterate over that field to extract data according to included_keys without knowing what exactly is in that model's field.
Hope this helps. Thanks.
okay, so regardless of the integration you want to be able to give such a field a full dict and have some keys filtered out.
Yeah, that's what I am thinking.
Go ahead and make the pull. I imagine by sub-classing DictField, you'll just have a minimal part to handle included_keys in the field from_native/to_native methods.
Thanks. I will make a pull request this weekend.
Hi, I just created a pull request for PartialDictField. Please review it. Honestly, this is my first time submit a pull request for an open source repo. So comments and suggestions are more than welcome. Thanks.
Pull was merged in, so closing this
@SonnyHu Decided to go ahead and cut an initial pre-release, so have at it! :P https://pypi.python.org/pypi/drf-compound-fields/0.1.0
Yes!!!!!
Hi, great work! I have been using a customized DictField which will include part of dict if users specify included_keys = []. The motivation is that for a django's json field [https://bitbucket.org/schinckel/django-jsonfield/], I only want to return part of the data inside of that field. I am not sure if you are ok if I create a pull request for this. Thanks.