Wednesday, November 30, 2011

Re: Django or python question about classes

Thanks for the link Tom.

I'll read that in details later (it's a little bit complicated) an for
my POC I'll just use a not DRY method !!! :-)

Regards

Youpsla

On 28 nov, 17:16, Tom Evans <tevans...@googlemail.com> wrote:
> On Mon, Nov 28, 2011 at 4:07 PM, youpsla <youp...@gmail.com> wrote:
> > 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
>
> http://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-are...
>
> Cheers
>
> Tom

--
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