Demo entry 6786014



Submitted by anonymous on Mar 22, 2019 at 10:29
Language: Python. Code size: 1.0 kB.

from django.db import models
from dcim.models import Device, Rack, Interface, InterfaceConnection

# Rear connection

# database table scs_rearconnection
class RearConnection(models.Model):
    id = models.AutoField(primary_key=True, help_text='Unique ID for this particular type')
    rack_a = models.ForeignKey('dcim.Rack', related_name='rack_a', on_delete=models.CASCADE)
    rack_b = models.ForeignKey('dcim.Rack', related_name='rack_b', on_delete=models.CASCADE)
    patchpanel_a = models.ForeignKey('dcim.Device', related_name='patchpanel_a', on_delete=models.CASCADE)
    patchpanel_b = models.ForeignKey('dcim.Device', related_name='patchpanel_b', on_delete=models.CASCADE)
    rearinterface_a = models.OneToOneField('dcim.Interface', related_name='rearinterface_a', on_delete=models.CASCADE)
    rearinterface_b = models.OneToOneField('dcim.Interface', related_name='rearinterface_b', on_delete=models.CASCADE)

# returns primary key
    def __str__(self):
        return str(

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).