django getting data and routing in view.py
in my project i have 3 action for users , my quest. is how can i route them
my code:
def featuresave(request):
layerId = request.POST.get("layid")
features = request.POST.get("feat")
if features == 'POINT': #( it includes Point string and coordinate as "POINT(38 39)"
als = Point()
als.layer = Layers.objects.get(id = layerId)
als.feature = features
als.save()
if feature == 'LINESTRING': #( it includes Linestring string and coordinate )
开发者_C百科als = Line()
als.layer = Layers.objects.get(id = layerId)
als.feature = feature
als.save()
if feature == 'POLYGON': #( it includes Linestring string and coordinate )
als = Poly()
als.layer = Layers.objects.get(id = layerId)
als.feature = feature
als.save()
return HttpResponse("OK")
thanks for your help
Looking at your comments, and assuming you are talking about what your request.POST.feat includes:
#( it includes Point string and coordinate as "POINT(38 39)"
#( it includes Linestring string and coordinate )
#( it includes Linestring string and coordinate )
and the comparisons before the comments... you aren't going to get a match...
Your comparisons should probably be something like
if feature.find('POINT') != -1:
#do something
elif feature.find('LINESTRING') != -1:
#do something
elif feature.find('POLYGON') != -1:
#do something
精彩评论