# How to delete a field

**URL:** https://discuss.tryton.org/t/how-to-delete-a-field/7617
**Category:** Developer
**Created:** [August 27, 2024, 5:09am UTC](https://discuss.tryton.org/t/how-to-delete-a-field/7617 "2024-08-27T05:09:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 27, 2024, 5:09am UTC](https://discuss.tryton.org/t/how-to-delete-a-field/7617/1 "2024-08-27T05:09:36Z")

</div>

So I want to delete a field from my module? Should I do it manually deleting it from my database? Or there is another way. Thank you.

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 27, 2024, 5:18am UTC](https://discuss.tryton.org/t/how-to-delete-a-field/7617/2 "2024-08-27T05:18:34Z")

</div>

Tryton will not delete fields from the database in order to avoid data loss.  
Once you have removed the ModelSQL class attribute that created the field, update your module (using trytond-admin -u MODULE or in Administration/Modules) and then drop the column(s) manually using sqlite/psql, while making sure that you are not losing data.

In the case of migration it is possible to do by code, so I guess it depends on your case.  
Here is an example: [modules/party/address.py · branch/default · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/blob/branch/default/modules/party/address.py?ref_type=heads#L318)

Btw, I found the example by doing: cd tryton/modules; grep -ri drop .

---

<div class="post-metadata">

### Author: ![mahija](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@mahija](https://discuss.tryton.org/u/mahija)
#### Post date: [August 27, 2024, 4:50pm UTC](https://discuss.tryton.org/t/how-to-delete-a-field/7617/3 "2024-08-27T16:50:13Z")

</div>

When you said

> “update your module using sqlite/psql”

do you mean when I do `trytond-admin`? It will create all the field i created in model?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 27, 2024, 6:29pm UTC](https://discuss.tryton.org/t/how-to-delete-a-field/7617/4 "2024-08-27T18:29:26Z")

</div>

> [@mahija](#):
>
> do you mean when I do `trytond-admin`? It will create all the field i created in model?

Yes but it may also remove column if you call [`TableHandler.drop_column`](https://docs.tryton.org/latest/server/ref/backend.html#trytond.backend.TableHandler.drop_column) for your field in the [`Model. __register__ `](https://docs.tryton.org/latest/server/ref/models.html#trytond.model.Model. __register__ ).  
But this means that the data in it will be lost.

---

<div class="post-metadata">

### Author: ![dotbit](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dotbit/32/2093_2.png) [@dotbit](https://discuss.tryton.org/u/dotbit)
#### Post date: [August 28, 2024, 5:18am UTC](https://discuss.tryton.org/t/how-to-delete-a-field/7617/5 "2024-08-28T05:18:57Z")

</div>

> [@mahija](#):
>
> “update your module using sqlite/psql”

BTW, I did not write that.  
The database may be updated using trytond-admin or by the interface at Administration/Modules.  
I would say that you may modify your database manually using sqlite/psql.
