Skip to content

Standardize on naming for ContentType fields #4711

@jeremystretch

Description

@jeremystretch

Proposed Changes

Update models in NetBox to use a standardized name for ForeignKey fields to the ContentType model. The name object_type is most appropriate IMO. Applicable fields include:

  • dcim.Cable
    • termination_a_type
    • termination_b_type
  • extras.CustomField
    • obj_type
  • extras.CustomFieldValue
    • obj_type
  • extras.CustomLink
    • content_type
  • extras.ExportTemplate
    • content_type
  • extras.Graph
    • type
  • extras.ImageAttachment
    • content_type
  • extras.ObjectChange
    • changed_object_type
    • related_object_type
  • extras.Webhook
    • obj_type
  • users.ObjectPermission
    • content_types (v2.9)

The proposal here is to rename fields named type, obj_type, or content_type to object_type. The Cable and ObjectChange models likely need no changes.

Justification

  • Standardizing on a common name readily conveys the purpose of the field.
  • object_type is more accurate than content_type and more apparent than obj_type. (type alone should be avoided due to its status as a reserved word in Python.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedThis issue has been accepted for implementationtype: housekeepingChanges to the application which do not directly impact the end user

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions