views:

33

answers:

1

How can I write a custom django validation for Google AppEngine.

The case is I have a model which has a field whose value should be greater than an already existing value in the datastore for the same attribute.

Thanks in advance.

A: 

The sample code is here: http://docs.djangoproject.com/en/1.1/ref/forms/validation/#cleaning-a-specific-field-attribute

You should run the code which checks the form.is_valid() and saving the entity in a transaction for consistency. Look at the 'isolation and consistency' section here: http://code.google.com/appengine/docs/python/datastore/transactions.html

dar