Open luzfcb opened 10 years ago
Thanks :)
Yes, you can achieve this in two different ways:
You can subclass a view and then register it to the viewset (I highly recommend this implementation):
from django.views.generic import UpdateView
from viewsets import ModelViewSet
class YourUpdateView(UpdateView):
success_url = '/your/custom/url'
class YourViewSet(ModelViewSet):
def __init__(self, *args, **kwargs):
self.views['update_view']['view'] = YourUpdateView
super(YourViewSet, self).__init__(*args, **kwargs)
Or by overriding keys of the views
attribute in your __init__
method.
The 'kwargs'
key can be used to override some view attributes or methods.
from viewsets import ModelViewSet
class YourViewSet(ModelViewSet):
def __init__(self, *args, **kwargs):
self.views['update_view']['kwargs'] = {'success_url': '/your/custom/url'}
super(YourViewSet, self).__init__(*args, **kwargs)
(I know, this is complex and implies a lot of code noise. That whole dict idea should be changed to an object-oriented approach.)
@BertrandBordage
Really cool your library. Is there any way to make it most customizable?
Individually customize the
form
forCreateView
andUpdateView
, individually customizesuccess_url
forCreateView
,UpdateView
,DeleteView
or use django-table2SingleTableView
instead ofListView
?