views:

22

answers:

1

Hello, I'm going to create some application with Django admin interface, with plugins in mind. For example I have some user class in billing application:

class User(models.Model):
    ContractNum = models.PositiveIntegerField(unique=True, blank=True, null=True ) 
    LastName = models.CharField(max_length=50,)

and I have cmdb application, which has another model:

class Switch(models.Model):
    Name = models.CharField(max_length=50, )
    Manufacturer = models.CharField(max_length=50, )
    Model = models.CharField(max_length=50, )

I would like to somehow virtually add to User model in billing application fields to have something like:

class User(models.Model):
    ContractNum = models.PositiveIntegerField(unique=True, blank=True, null=True ) 
    LastName = models.CharField(max_length=50,)
    Switch = models.ForeignKey(Switch, related_name='SwitchUsers')

when I'm installed application cmdb, without any change in billing application dynamically.

I've read about abstract class, but I don't see the way how to achieve what I want with it, because it will add User into cmdb application, and I want something keep billing without changes as main application for the project.

A: 

Create a third model with has a OneToOne to User and a ForeignKey to Switch.

Ignacio Vazquez-Abrams