A more efficient way is to specify a foreign key by adding "_id" at the end, for example:
cs = Point(layers_id = mid, meta = metas) cs.save()
DO NOT run layers = XXX.objects.get (id = ###), as this doubles the number of database queries.
ALSO ... you are not clearing the POST data here, which is pretty dangerous. Get it like this:
from django import forms id_field = forms.IntegerField() layer_id = id_field.clean(request.POST.get("layerId", "")
hendrixski
source share