django在view.py中获取数据和路由
在我的项目中,我的任务是为用户提供 3 个操作。我怎样才能将
我的代码路由给他们:
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 )
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")
感谢您的帮助
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 )
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看您的评论,并假设您正在谈论您的 request.POST.feat 包括的内容:
以及评论之前的比较...您不会获得匹配...
您的比较可能应该是这样的
Looking at your comments, and assuming you are talking about what your request.POST.feat includes:
and the comparisons before the comments... you aren't going to get a match...
Your comparisons should probably be something like