需要在app-engine / django表单中GeoPtProperty上的指针 [英] need pointer on GeoPtProperty in app-engine/django forms

查看:125
本文介绍了需要在app-engine / django表单中GeoPtProperty上的指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是在寻找一种错误修复方法,而是一种方法。我是一个简单模型的新手:

I'm not looking for a bug fix so much as an approach. I'm a newbie with a simple model:


classLocation(db.Model):
    name = db.StringProperty()
    geoPt = db.GeoPtProperty()
    ...

我用它来做一个简单的形式:

I use that to make a simple form:


class LocationForm(djangoforms.ModelForm):
    class Meta:
        model = Location

呈现出来时,GeoPt是一个单独的文本字段。对于这种形式,我更愿意使用经纬度字段和验证。

When it renders out, the GeoPt is a single text field. For this form I'd prefer latitude and longitude fields, with validation.

要走哪条路?这是Django表单中复杂对象的常见问题吗?如果是这样,是否有一个公认的解决方案?

Which way to go? Is this a common problem with "complex objects" in django forms? If so, is there an accepted solution?

推荐答案

这是一个复合类型的问题,工作。

It is a problem with compound types and the way database-schema derived UI has to work.

你会更好地减少重量并运行专门的表单处理库,比如 flatland WTForm FormEncode fungiform ,或者甚至是自制的替代品。

You'll be much better off dropping the deadweight and running a specialized form processing library, like flatland, WTForm, FormEncode, fungiform, or indeed even a homegrown alternative.

用户输入验证并不是一个难题,而且通过复制数据库模式验证并不总是更容易。

User-input validation is not a hard problem, and it certainly doesn't always get easier by copying the database schema validation.

这篇关于需要在app-engine / django表单中GeoPtProperty上的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆