Thomas
Thomas

Reputation: 8950

Can I change a default property in appengine model?

I didn't read the doc enough before starting this, my mistake. I have :

class A(db.Model):
  date = db.DateTimeProperty(auto_now_add=True)

I would prefer auto_now=True instead. Can I just change it ? I know that a change won't affect existing data (i.e it won't magically change the date of objects in the datastore to their last update date).

Bu what will happen to entities that were created with the auto_now_add=True ? Is a model transformation like that permitted ? Or will this just affect new objects ?

I can reformulate my questions if I am not clear, don't hesitate to ask

Upvotes: 1

Views: 41

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599610

This is not a model transformation. auto_now and auto_now_add are applied entirely in the Python db client, not at the datastore level. You can change it whenever you like, and all entities that you modify after making that change (as long as you're using the new code) will update the date field when put() is called.

Upvotes: 2

Related Questions