Monday, November 28, 2011

Django or python question about classes

Hello,
in my code, I like to overrride the form_valid() method in both
CreateView and UpdateView generic class views.

I've put my code in views.py.

class MyCreateView(UpdateView):
.....
def form_valid(self, form, **kwargs):
some code

class MyUpdateView(CreateView):
.....
def form_valid(self, form, **kwargs):
some code

The both form_valid() methods are exactly the same (Only the
dispatch() method differ from both classes).

My question is : is there a way of doing this more in a DRY way ?

Thanks in advance.

Best regards

Alain

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment