# modifiing models of existing apps

**URL:** <https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695>\
**Category:** ORM\
**Created:** [July 8, 2021, 7:01pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695 "2021-07-08T19:01:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:01pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/1 "2021-07-08T19:01:22Z")

</div>

hi django forum,

i’m using django for my latest project and im very satisfied, but im missing one feature. openobject, odoos ORM framework makes it possible to extend the models of existing apps, not deriving from it.

this means you can put new fields in models of e.g. an existing crm app without rewriting the controllers and views. they call that delegation inheritance.

in other words. you can make addon1 which extends the customer model of the base crm app and a addon2 which extends the same model with another field and the logic behind it.

now i can have costomer 1 who needs addon1 and customer 2 who needs addon2 and customer 3 who needs both.

if i havent misunderstood something, in django you always make a complete new app and just pull out some models. so you need new controllers and views if you want the same functionality as in the base app or copy and paste the ones from it.

i know - this is only possible by using xml based templating engines and django comes with a html based, but perhaps somebody did a hack for this purpose.

greetings and stay healthy

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 7:05pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/2 "2021-07-08T19:05:04Z")

</div>

See the Django docs for [model inheritance](https://docs.djangoproject.com/en/3.2/topics/db/models/#model-inheritance) to see how this is done in Django.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 7:10pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/3 "2021-07-08T19:10:50Z")

</div>

Also, regarding your comparison to ODOO, it’s apples and pumpkins. They’re completely different products addressing separate functional areas. (Django could be something you would use to build something like ODOO - not use it as a replacement for it.)

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:12pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/4 "2021-07-08T19:12:16Z")

</div>

hi ken,

thanks for your quick answer. of course i have already read the documentation, but there is nothing to read about a feature which is similar to delegation inheritance.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 7:15pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/5 "2021-07-08T19:15:10Z")

</div>

Please define (or provide a reference to something that defines) “delegation inheritance”.

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:21pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/6 "2021-07-08T19:21:05Z")

</div>

yes youre absolutely right. and for the purpose odoo is made i will further use odoo.

but i have compared open object and django, not odoo and django. openobject is not available without the rest of the application, so im searching for a replacement for openobject.

pure django gives not the whole functions openobject has but is quite flexible, so im asking if anyone has brought this one or two features into django by an addon or so

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:23pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/7 "2021-07-08T19:23:40Z")

</div>

not much better than my explanation …  
[Inheritance - Delegation Inheritance in Odoo 13 | Odoo Tutorials](https://www.cybrosys.com/odoo-development-tutorial/v13/delegation-inheritance-odoo-13/#:~:text=In%20Odoo%20we%20can%20inherit,model%20without%20affecting%20the%20views).

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 7:25pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/8 "2021-07-08T19:25:35Z")

</div>

What features are you looking for? If you’re referring to what ODOO identifies as “delegation inheritance”, I’d need to know what that _is_ before I can offer any suggestions. There’s no glossary that I can find on [odoo.com](http://odoo.com) that defines it outside of an example of how it’s used. (And no, I’m not going to spend 15 minutes trying to watch a video to extract a definition that would take me 15 seconds to read.)

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:33pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/9 "2021-07-08T19:33:43Z")

</div>

i was wrong. what im searching for is not called delegation inheritance. its the first type of inheritance

you can read it here

## Inheritance and extension

on  
[https://www.odoo.com/documentation/12.0/developer/reference/orm.html#inheritance-and-extension](https://www.odoo.com/documentation/12.0/developer/reference/orm.html#inheritance-and-extension)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 7:39pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/10 "2021-07-08T19:39:07Z")

</div>

If this is the “first type” you’re referencing:

- creating a new model from an existing one, adding new information to the copy but leaving the original module as-is

(That’s the first bullet from the link you provided)

That’s standard Django model inheritance.

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:40pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/11 "2021-07-08T19:40:09Z")

</div>

im afraid the anchors are not working on this site. please search for inheritance

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 7:40pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/12 "2021-07-08T19:40:59Z")

</div>

Might be easier if you just copy/pasted the applicable text rather than me trying to guess what you’re making references to. (Or at least enough of a snippet to provide some context.)

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:41pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/13 "2021-07-08T19:41:42Z")

</div>

no in django you only modify the class not the object

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 7:43pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/14 "2021-07-08T19:43:22Z")

</div>

sorry the second one

> extending models defined in other modules in-place, replacing the previous version

so existing apps show my new fields inside their views

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 7:58pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/15 "2021-07-08T19:58:43Z")

</div>

An object is an instance of a class - I don’t follow what you’re trying to say there.

- extending models defined in other modules in-place, replacing the previous version

Ok, I can see the point here - if you extend a predefined model, your extended class is going to be a new table and not an extension of that existing table.

Something about this is tickling the hair on the back of my neck - I need to do a little more reading about this before I can provide an appropriate response.

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 8:01pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/16 "2021-07-08T20:01:11Z")

</div>

its not easy to explain. i will provide some screenshots tomorrow

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 8:04pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/17 "2021-07-08T20:04:27Z")

</div>

yes but the point of intrest is what openobject is doing with the new table. i come back with screenshots tomorrow

---

<div class="post-metadata">

**Author:** ![franzbrandtwein](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/franzbrandtwein/32/5080_2.png) [@franzbrandtwein](https://forum.djangoproject.com/u/franzbrandtwein)\
**Post date:** [July 8, 2021, 8:31pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/18 "2021-07-08T20:31:50Z")

</div>

pythons default behaviour for inheritance ist combining the base class and the child class to one and creating an object out of this aggregate.  
inheritance in openobject when

- extending models defined in other modules in-place, replacing the previous version  
is different. it instanciates the base class … and then it applies the changes introduced by a class which is inherited from the base class. which means its shown in the same view under the same url as the app to which the base class belongs has intended.

thats what i meant as i said modify the class not the object (i know that’s nonsense in object orientated terminology, it’s odoo specific)

in django you always pull models and function from base apps into your own apps by inheritance. you cannot push models, fields and functions into base apps. or am i wrong?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 8:37pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/19 "2021-07-08T20:37:57Z")

</div>

> [@franzbrandtwein](#):
>
> in django you always pull models and function from base apps into your own apps by inheritance. you cannot push models, fields and functions into base apps. or am i wrong?

Technically, that is correct. However, since you can override existing templates, views and URLs, it’s a difference that makes no difference.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 8, 2021, 8:42pm UTC](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695/20 "2021-07-08T20:42:42Z")

</div>

> [@franzbrandtwein](#):
>
> pythons default behaviour for inheritance ist combining the base class and the child class to one and creating an object out of this aggregate.

That’s true as being Python’s standard behavior. However, that’s not required within Django. The two types of inheritance are to do as you describe, _or_ create a OneToOne relationship between your extensions and the base model. (What Django refers to as the “Profile” model.)

[Next page](https://forum.djangoproject.com/t/modifiing-models-of-existing-apps/8695.md?page=2)
