django在view.py中获取数据和路由

发布于 2024-10-19 04:32:12 字数 783 浏览 1 评论 0原文

在我的项目中,我的任务是为用户提供 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

困倦 2024-10-26 04:32:12

查看您的评论,并假设您正在谈论您的 request.POST.feat 包括的内容:

 #( it includes Point string and coordinate as "POINT(38 39)" 
 #( it includes Linestring string and coordinate )
 #( it includes Linestring string and coordinate )

以及评论之前的比较...您不会获得匹配...

您的比较可能应该是这样的

if feature.find('POINT') != -1:
    #do something
elif feature.find('LINESTRING') != -1:
    #do something
elif feature.find('POLYGON') != -1:
    #do something

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文