in my model.py
class Layer(models.Model):
user = models.IntegerField()
name = models
...
class Point(models.Model):
layers = models.ForeignKey(Layer)
meta = models.TextField()
...
in my view.py
def datasave(request, id):
mid = request.POST.get("layerid",default = "")
metas = request.POST.get("meta",default = "")
cs = Point()
cs.layers = mid
cs.meta = metas
cs.save()
but it gives an error in my django debug..in my project i use geodjango,openlayers and extjs… i didnt find any solution about saving my post
i didnt make any relation with my foreignkey.. basically i want to make a layer than when i want to add a point in my layer , i want save my point with layer id….
It’s helpful to post the traceback to help understand your problem (for future questions).
It looks to me like you are passing in a number to your
Pointinstance’slayersattribute which would cause aValueError. The only place you can pass a number to a foreign key field is in a django form which does the lookup for you.You need to assign an actual
Layerinstance instead.