django.db.utils.IntegrityError: null value in column “layer_id_id” violates not-null constraint . How to debug ?
his is my 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)
# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models
# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models
class Test(models.Model):
layer_id= models.ForeignKey(Sdr_Layer)
name = models.CharField(max_length=80)
descriptio = models.CharField(max_length=80)
geom = models.PolygonField(srid=4326)
objects = models.GeoManager()
S = Sdr_Layer(layer_name="Test")
# Auto-generated `LayerMapping` dictionary for Test model
test_mapping = {
'name' : 'Name',
'descriptio' : 'Descriptio',
'geom' : 'POLYGON25D',
}
S.layer_attribute_name=test_mapping
S.save();
When I am trying to load data to Test model , it throws me a not_null
error on layer_id which is the foreign key here . I basically want the
primary key of Sdr_Layer to act as a foreign key here . Sdr_Layer
table does have values . So , why such an error ?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home