app asterisk models py from django db import models class Sip models M

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#app/asterisk/models.py
from django.db import models
class Sip(models.Model):
name = models.CharField(max_length=20, null=False, blank=False)
...
#app/provisioninig/models.py
from django.db import models
from app.asterisk.models import *
from app.provisioning import prov
class Device(models.Model):
mac = models.CharField(max_length=12, unique=True)
...
class Line(models.Model):
device = models.ForeignKey(Device)
sip = models.ForeignKey('asterisk.Sip', unique=True)
....
def save(self):
prov.make_smth(self.device)
super(Line, self).save()
#app/provisioning/prov.py
from app.asterisk.models import *
from app.provisioning.models import *
def make_smth(device):
lines = Line.objects.filter(device__mac = device.mac).values()