Change Graph.type to a ContentType ForeignKey #3046

Closed
opened 2025-12-29 18:25:08 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 5, 2019).

Proposed Changes

On extras.Graph, change

    type = models.PositiveSmallIntegerField(
        choices=GRAPH_TYPE_CHOICES
    )

to (roughly)

    type = models.ForeignKey(
        to=ContentType,
        on_delete=models.CASCADE,
        limit_choices_to=GRAPH_TYPE_CHOICES
    )

Justification

This brings the field into line with similar fields on other objects (e.g. ExportTemplate.content_type) and obviates the need for a set of static choice values.

This does not modify the set of models to which an ExportTemplate can be assigned, which currently includes interfaces, devices, providers, and sites.

Originally created by @jeremystretch on GitHub (Dec 5, 2019). ### Proposed Changes On `extras.Graph`, change ```python type = models.PositiveSmallIntegerField( choices=GRAPH_TYPE_CHOICES ) ``` to (roughly) ```python type = models.ForeignKey( to=ContentType, on_delete=models.CASCADE, limit_choices_to=GRAPH_TYPE_CHOICES ) ``` ### Justification This brings the field into line with similar fields on other objects (e.g. `ExportTemplate.content_type`) and obviates the need for a set of static choice values. This does not modify the set of models to which an ExportTemplate can be assigned, which currently includes interfaces, devices, providers, and sites.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 18:25:08 +01:00
adam closed this issue 2025-12-29 18:25:08 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3046