RSS

Blog

Django: Avoiding redundancy with inheritance

h314 May 2009 –  Comments (3)

Comments

I have used abstract model for inheritance before, it is a good idea to have a model that has the basic who and when information to use on with other models.

Thanks.

[] Vitaly Babiy ~ 9 months, 1 week ago at 1:56 p.m.

thanks for this excellent tip and writeup. i made one small addition to your ModelAdmin class so that the created_by and modified_by fields don't show up on the change form.

[] pjv ~ 7 months, 2 weeks ago at 1:25 p.m.

...and i was trying to put the code into that comment above using the "code highlight" documentation, but i guess i couldn't get the preview working right and then when i clicked preview a second time on the preview page, it posted!

so anyway, all i did to exclude those fields was add the following line

exclude = ('created_by','modified_by',)

right after the Class definition line and before the first method definition

[] pjv ~ 7 months, 2 weeks ago at 1:32 p.m.

Copyrighted stuff .. u know.