Skip to content

Custom field detail page shows internal model name for related_object_type instead of verbose name #22247

@bctiemann

Description

@bctiemann

Environment

NetBox version: main

Steps to Reproduce

  1. Create any Custom Field of type Object or Multi-object and set a Related Object Type (e.g. select "IP Address" or any model from a plugin that uses an internal model name).
  2. Open the detail page for that Custom Field.

Expected Behavior

The Type field shows the human-readable verbose name, e.g. Object (IP Address) or Object (Cat).

Actual Behavior

The Type field shows the raw Django ContentType model name run through bettertitle, e.g.:

  • Object (Ipaddress) for IP Address (model name ipaddress)
  • Object (Table24model) for a model from the netbox-custom-objects plugin (whose dynamic models are named table<id>model)

Root Cause

templates/extras/customfield/attrs/type.html uses:

{{ object.related_object_type.model|bettertitle }}

ContentType.model is the raw lowercase model name (e.g. ipaddress, table24model). bettertitle only capitalises the first letter of each space-separated word, so single-word or programmatic names are not made human-readable.

ContentType.name is the correct property — it returns capfirst(model._meta.verbose_name) (e.g. IP address, Cat), falling back to model when the model class is not registered.

Fix

Change the template to use related_object_type.name instead of related_object_type.model:

{{ object.related_object_type.name|bettertitle }}

This also improves the display of existing NetBox models: IP Address currently renders as Ipaddress; with the fix it renders as IP Address.

Metadata

Metadata

Assignees

Labels

netboxseverity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions