Comments (8)
That would be awesome.
from django-rest-framework-bulk.
I am going to be taking a look at it in the next week.
from django-rest-framework-bulk.
While I haven't tried it out, this should be supported if you do not use routers. When initializing the urlpattern, you would just need to link the post/put/patch/delete views using as_view()
. Modifying the routers to make it work there is a different story of course, as you would have to override the list route.
from django-rest-framework-bulk.
It totally work as expected, I've been able to setup a BulkUpdateViewSet with straightforward mixins :
class UserViewSet(BulkUpdateModelMixin, viewsets.ModelViewSet):
model = User
class BulkUpdateRouter(DefaultRouter):
routes = SimpleRouter.routes
routes[0] = Route(
url=r'^{prefix}{trailing_slash}$',
mapping={
'get': 'list',
'post': 'create',
'put': 'bulk_update',
'patch': 'partial_bulk_update'
},
name='{basename}-list',
initkwargs={'suffix': 'List'}
)
router = BulkUpdateRouter()
router.register(r'users', UserViewSet)
Adding DELETE would be a breeze as well (but I don't need it)
from django-rest-framework-bulk.
👍 @thomasWajs
I actually never needed to use ViewSets for my projects since I needed fine-grained control and making APIViews did not seem so difficult. Thanx for posting example of how to integrate with ViewSets. If you want, you can add this into Readme and submit PR.
from django-rest-framework-bulk.
@thomasWajs if possible, can you please add an example of a request that can be made against bulk_update, or partial_bulk_update? I'm a bit baffled by this. Thank you!
from django-rest-framework-bulk.
PATCH /users/?is_admin=1
is_staff=1
Would do a partial update on all user that are admin, to set them staff as well.
The filtering mechanism uses the one builtin rest-framework, which relies on django-filter
from django-rest-framework-bulk.
Thank you so much!
from django-rest-framework-bulk.
Related Issues (20)
- POST on Browsable API fails because of get_initial
- Default allow_bulk_destroy implementation does the opposite of its documentation HOT 1
- UUIDs are not handled HOT 4
- README bug
- AttributeError: 'QuerySet' object has no attribute 'pk' when doing bulk update HOT 15
- how to validate the list when I create (怎么在创建的时候校验整个提交过来的list数据) HOT 2
- AttributeError: type object 'ContactsViewSet' has no attribute 'get_extra_actions' HOT 5
- Project status HOT 7
- permission_classes in ListBulkCreateUpdateAPIView HOT 1
- URL syntax for Bulk modifications HOT 1
- POST 400 (Bad Request) HOT 1
- is it possible to override put?
- Archive the project as it's dead HOT 4
- This contex generaly doesn't exist
- Field Unique fails when trying to bulk update
- if self.instance causes queryset to be evaluated
- Not displayed on the web page
- import BulkSerializerMixin err
- Adding BulkUpdateMixin will cause duplicate queries
- BulkListSerializer.update获取obj_id,当数据库中的类型为int时,会导致后续的get取不到obj_validated_data HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rest-framework-bulk.