实现django模型时出错。怎么调试?

时间:2011-06-08 08:51:32

标签: django-models

Error: One or more models did not validate:
maps.parking: 'layer_id' has a relation with model sdr_layer.Sdr_layer, which has either not been installed or is abstract.

这是我的错误。

My maps/models.py looks like this 
# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models

class Parking(models.Model):
    layer_id= models.ForeignKey(sdr_layer.Sdr_layer)
    name = models.CharField(max_length=80)
    descriptio = models.CharField(max_length=80)
    geom = models.PointField(srid=4326)
    objects = models.GeoManager()

# Auto-generated `LayerMapping` dictionary for Parking model
parking_mapping = {
    'name' : 'Name',
    'descriptio' : 'Descriptio',
    'geom' : 'POINT25D',
}

sdr_layer / models.py看起来像这样

from django.db import models

    class Sdr_Layer(models.Model):
       layer_name = models.CharField(max_length = 100)
       layer_attribute_name = models.CharField(max_length = 100)

我基本上希望Sdr_layer.id充当app地图的外键。

2 个答案:

答案 0 :(得分:2)

确保sdr_layer列在settings.py

中的INSTALLED_APPS中

答案 1 :(得分:0)

我认为您打算models.ForeignKey(sdr_layer.Sdr_Layer)