O nadpisywaniu pól i polami.
Jak wszyscy wiemy Django
umożliwia dziedziczenie modeli w dodatku
na klika sposobów. Jednak ma pewne ograniczenia. Nie można np.
nadpisać pola z modelu bazowego nowym polem. Jak czytamy w dokumentacji:
This restriction only applies to attributes which are Field instances. Normal Python attributes can be overridden if you wish. It also only applies to the name of the attribute as Python sees it: if you are manually specifying the database column name, you can have the same column name appearing in both a child and an ancestor model for multi-table inheritance (they are columns in two different database tables).
Jendakże... Co się stanie kiedy będziemy chcieli nadpisać nie pole, a polem? Np. tworząc pole o nazwie takiej samej jak @property z modelu bazowego?
Odpowiedź: Otrzymamy AttributeError. o treści "can't set attribute".
Pełne case study dostępne
jako ticket na code.djangoproject.com.