Add a Textarea custom field type #5047

Closed
opened 2025-12-29 19:23:31 +01:00 by adam · 9 comments
Owner

Originally created by @hiddenman on GitHub (Jul 7, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.8

Feature type

Data model extension

Proposed functionality

Add a Textarea custom field type

Use case

Currently it's not possible to add a multi-line custom field. Only single line text field is supported.

It's often required to add some notes or comments to a particular cable/port/whatever.
For example, our cables have multi-line stickers like:

dsp-fg-1  mgmt2
dsp-fg-2  mgmt2

and there is no way to store them with a proper formatting.

Database changes

No response

External dependencies

No response

Originally created by @hiddenman on GitHub (Jul 7, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.8 ### Feature type Data model extension ### Proposed functionality Add a Textarea custom field type ### Use case Currently it's not possible to add a multi-line custom field. Only single line text field is supported. It's often required to add some notes or comments to a particular cable/port/whatever. For example, our cables have multi-line stickers like: ``` dsp-fg-1 mgmt2 dsp-fg-2 mgmt2 ``` and there is no way to store them with a proper formatting. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:23:31 +01:00
adam closed this issue 2025-12-29 19:23:31 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 12, 2021):

Given your example, it seems like raw JSON support might be more suitable for your use case.

@jeremystretch commented on GitHub (Jul 12, 2021): Given your example, it seems like raw JSON support might be more suitable for your use case.
Author
Owner

@hiddenman commented on GitHub (Jul 12, 2021):

Given your example, it seems like raw JSON support might be more suitable for your use case.

Hi,

In this case it might be enough. What about other descriptions/notes?
I've checked Django supported types, models.TextField() is suitable there, isn't it?

@hiddenman commented on GitHub (Jul 12, 2021): > Given your example, it seems like raw JSON support might be more suitable for your use case. Hi, In this case it might be enough. What about other descriptions/notes? I've checked Django supported types, models.TextField() is suitable there, isn't it?
Author
Owner

@hiddenman commented on GitHub (Jul 12, 2021):

And i can't find any kind of JSON field type in the Django docs, can you?

@hiddenman commented on GitHub (Jul 12, 2021): And i can't find any kind of JSON field type in the Django docs, can you?
Author
Owner

@jeremystretch commented on GitHub (Jul 12, 2021):

NetBox does not employ Django model fields for custom fields. Custom field data is stored as JSON in the custom_field_data field on each model. If you'd like to become more familiar with how custom fields work, please review the code here and here (and probably some other places I can't think of).

Because all custom field data is stored as JSON, we have a lot of flexibility over what to store. However, we also need to be wary of overdeveloping the custom fields feature into a sort of mini NoSQL database.

@jeremystretch commented on GitHub (Jul 12, 2021): NetBox does not employ Django model fields for custom fields. Custom field data is stored as JSON in the `custom_field_data` field on each model. If you'd like to become more familiar with how custom fields work, please review the code [here](https://github.com/netbox-community/netbox/blob/develop/netbox/extras/models/customfields.py) and [here](https://github.com/netbox-community/netbox/blob/fd7d8cbf5604bd9dd1b88d13f1fbc000c0c88e47/netbox/netbox/models.py#L74) (and probably some other places I can't think of). Because all custom field data is stored as JSON, we have a lot of flexibility over what to store. However, we also need to be wary of overdeveloping the custom fields feature into a sort of mini NoSQL database.
Author
Owner

@hiddenman commented on GitHub (Jul 12, 2021):

NetBox does not employ Django model fields for custom fields. Custom field data is stored as JSON in the custom_field_data field on each model. If you'd like to become more familiar with how custom fields work, please review the code here and here (and probably some other places I can't think of).

Because all custom field data is stored as JSON, we have a lot of flexibility over what to store. However, we also need to be wary of overdeveloping the custom fields feature into a sort of mini NoSQL database.

Ok, thank you. As far as i understand you can just add/allow JSONField() as custom field type?
I was looking through the code to understand how it works and thought it was related to the Django model.

@hiddenman commented on GitHub (Jul 12, 2021): > NetBox does not employ Django model fields for custom fields. Custom field data is stored as JSON in the `custom_field_data` field on each model. If you'd like to become more familiar with how custom fields work, please review the code [here](https://github.com/netbox-community/netbox/blob/develop/netbox/extras/models/customfields.py) and [here](https://github.com/netbox-community/netbox/blob/fd7d8cbf5604bd9dd1b88d13f1fbc000c0c88e47/netbox/netbox/models.py#L74) (and probably some other places I can't think of). > > Because all custom field data is stored as JSON, we have a lot of flexibility over what to store. However, we also need to be wary of overdeveloping the custom fields feature into a sort of mini NoSQL database. Ok, thank you. As far as i understand you can just add/allow JSONField() as custom field type? I was looking through the code to understand how it works and thought it was related to the Django model.
Author
Owner

@sleepinggenius2 commented on GitHub (Aug 4, 2021):

I just wanted to second the textarea custom field type. It would be really nice to also allow for it to support markdown rendering (could be an option). We are looking to break out site data for things like driving directions and access information, so that they can be updated easily without clobbering other data in the comments field, as well as being displayed consistently for field technicians. It would be really helpful to have markdown support there to add things like links, lists, and tables.

@sleepinggenius2 commented on GitHub (Aug 4, 2021): I just wanted to second the textarea custom field type. It would be really nice to also allow for it to support markdown rendering (could be an option). We are looking to break out site data for things like driving directions and access information, so that they can be updated easily without clobbering other data in the comments field, as well as being displayed consistently for field technicians. It would be really helpful to have markdown support there to add things like links, lists, and tables.
Author
Owner

@hiddenman commented on GitHub (Sep 24, 2021):

Hi,

I'm filling a new feature request to the secretstore plugin and just realized that it requires a textarea customfield to be implemented.
I want to store ssh private keys, SSL certificates keys and so on.

Right now, when i save my private key it becomes broken and messed after saving.

So it would be really great to have something like textarea/JSON.

@hiddenman commented on GitHub (Sep 24, 2021): Hi, I'm filling a new feature request to the secretstore plugin and just realized that it requires a textarea customfield to be implemented. I want to store ssh private keys, SSL certificates keys and so on. Right now, when i save my private key it becomes broken and messed after saving. So it would be really great to have something like textarea/JSON.
Author
Owner

@geor-g commented on GitHub (Sep 24, 2021):

Hi,

I'm filling a new feature request to the secretstore plugin and just realized that it requires a textarea customfield to be implemented.
I want to store ssh private keys, SSL certificates keys and so on.

Right now, when i save my private key it becomes broken and messed after saving.

So it would be really great to have something like textarea/JSON.

@hiddenman As a workaround, you could encode it, for example via base64.

@geor-g commented on GitHub (Sep 24, 2021): > Hi, > > I'm filling a new feature request to the secretstore plugin and just realized that it requires a textarea customfield to be implemented. > I want to store ssh private keys, SSL certificates keys and so on. > > Right now, when i save my private key it becomes broken and messed after saving. > > So it would be really great to have something like textarea/JSON. @hiddenman As a workaround, you could encode it, for example via base64.
Author
Owner

@jeremystretch commented on GitHub (Oct 5, 2021):

I think it makes sense to add a new longtext custom field type for free-form text. This would render as a <textarea> HTML form widget, and would support Markdown rendering similar to comments. I'm going to mark this as needs milestone with the assumption that this approach satisfies the proposal.

Separately, I've opened #7452 to discuss adding a JSON custom field type.

@jeremystretch commented on GitHub (Oct 5, 2021): I think it makes sense to add a new `longtext` custom field type for free-form text. This would render as a `<textarea>` HTML form widget, and would support Markdown rendering similar to comments. I'm going to mark this as `needs milestone` with the assumption that this approach satisfies the proposal. Separately, I've opened #7452 to discuss adding a JSON custom field type.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5047