MattBroach / DjangoRestMultipleModels

View (and mixin) for serializing multiple models or querysets in Django Rest Framework
MIT License
549 stars 67 forks source link

If flat=True, I want to add one more field to merge two lists & provide a custom merge function #11

Closed anujism closed 8 years ago

anujism commented 8 years ago

How can I extend this to add a new field based on which return the results?

For eg. before calling queryList_sort function, I would like to call a custom queryList_merge function.

MattBroach commented 8 years ago

That should be a pretty easy refactor: I'll just move the merging process to a separate function that you'll be able to overwrite in your view. I'm a little swamped this week, but I'll get to this over the weekend. I'll also add an example of using filter_fn to the documentation, per your other request.

MattBroach commented 8 years ago

Sorry for the delay -- took me awhile to find the time to make an update. I have moved part of the mixin into a format_data() function, which handles how serialized data is formatted and combined in the running total. You should be able to override that in your specific view to get the functionality you're looking for.

anujism commented 8 years ago

Thanks. This is exactly what I needed. This library is a great help.