need pointer on GeoPtProperty in app-engine/django forms

帅比萌擦擦* 提交于 2019-12-24 10:27:10

问题


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

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

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/4743897/need-pointer-on-geoptproperty-in-app-engine-django-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!