ich würde gern zwei Models aus zwei verschiedenen Apps verknüpfen. Leider geht es nicht. Ich bekomme immer die Fehlermeldung:
"ImportError: cannot import name Station"
Model.py der App "Devices"
Code: Alles auswählen
from Climate.models import Room
from django.db import models
CPU_TYPES = (
('1', 'Amtel ATMEGA 328'),
('2', 'Amtel ATMEGA 2560'),
)
STATION_TYPES = (
('1', 'inhouse metering'),
('2', 'outdoor metering'),
('3', 'surveillance'),
)
SENSOR_TYPES = (
('1', 'temperature'),
('2', 'humidity'),
('3', 'noise'),
('4', 'light'),
)
class Station(models.Model):
name = models.CharField(max_length = 20)
cpu = models.CharField(max_length=1, choices=CPU_TYPES, default='1')
type = models.CharField(max_length=1, choices=STATION_TYPES, default='1')
room = models.ManyToManyField(Room, blank=True, null=True)
def __unicode__(self):
return self.name
class Sensor(models.Model):
name = models.CharField(max_length = 30)
type = models.CharField(max_length=1, choices=SENSOR_TYPES, default='1')
station = models.ManyToManyField(Station, blank=True, null=True)
def __unicode__(self):
return self.name
class ValueStorage(models.Model):
station = models.ForeignKey(Station);
sensor = models.ForeignKey(Sensor)
def __unicode__(self):
return (self.station, self.station)
class Value(models.Model):
station = models.ForeignKey(ValueStorage)
value = models.DecimalField(decimal_places=2,max_digits=4)
Code: Alles auswählen
from Devices.models import Station
from django.db import models
class Room(models.Model):
name = models.CharField(max_length=30)
size = models.DecimalField(decimal_places=2, max_digits=4)
station = models.ForeignKey(Station, blank=True, null=True)
def __unicode__(self):
return self.name
class Light(models.Model):
name = models.CharField(max_length=20)
location = models.ForeignKey(Room)
def __unicode__(self):
return self.name
Woran liegts?
Gruß und Dank
Peter