Just create another CBV that factors out all of the similarities between all of 
the other CBVs.  Then inherit from your new CBV to create your more specific 
ones.  Basically instead of inheriting from the Django CBVs, you will inherit 
from your own.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Artem Bernatskyy
Sent: Friday, November 4, 2016 10:56 AM
To: Django users
Subject: Class Based Views VS DRY principle

Hello.

Suppose i have a code (http://pastebin.com/6rUqKD8q)

And in CBV there are a bunch of methods with EXACTLY the same code.

My question is - can i somehow inherit them from ONE place, in order to be able 
to edit them from one place ?

Thanks for replies.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/51ca427d-732a-4223-bf27-59fa7b346295%40googlegroups.com<https://groups.google.com/d/msgid/django-users/51ca427d-732a-4223-bf27-59fa7b346295%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9498a12178a74e8a985b8d744d6e3403%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.

Reply via email to