Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 874443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:06:16+00:00 2026-05-15T11:06:16+00:00

I have a Model in an existing Datastore. Which looks like this: class SomeKind(db.Model):

  • 0

I have a Model in an existing Datastore. Which looks like this:

class SomeKind(db.Model):
  name = db.StringProperty(required=True)
  someField = db.BlobProperty(required=True)

There are about 20000+ entities, of this kind, in the datastore
Now I want to restructure the kind and make it this way:

class SomeKind(db.Model):
  name = db.StringProperty(required=True)
  someField = db.StringProperty(required=True)

I think I have to

  1. Cycle through the datastore to remove existing “someField” data. from models.py
  2. Remove the property
  3. Add the property, with new definition, to models.py

I’m stucked at (1) where I want to delete existing attribute with remote API:

import sys, time, urllib2

sys.path.append("gae/paths")
...
sys.path.append("myapp/path")
from google.appengine.ext import db
from google.appengine.api import memcache
from google.appengine.ext.remote_api import remote_api_stub
from models import *

def tryPut(db, set, tryLimit=10, seconds=5, trying=1):
  try:
    db.put(set)
    return True
  except urllib2.HTTPError:
    if trying <= tryLimit:
      print "retry (%d of %d) in 5 seconds" % (trying, tryLimit)
      time.sleep(5)
      tryPut(db, set, seconds, trying+1)
    else:
      print urllib2.HTTPError
      sys.exit()

def main():

    remote_api_stub.ConfigureRemoteDatastore(None, 
      '/remote_api', my_auth_func, 'myapp.appspot.com')
    q = db.GqlQuery("SELECT * FROM SomeKind")
    last_cursor = memcache.get('SomeKind/update')

    if last_cursor:
        q.with_cursor(last_cursor)

    set = q.fetch(100)

    while len(set) != 0:
      for someKind in set:
        print someKind.name

        # this doesn't work
        delattr(someKind, "someField")

        # this doesn't work either
        del someKind.someField

      print "update to Google"
      if tryPut(db, set):
        cursor = q.cursor()
        memcache.set('SomeKind/update', cursor)

if __name__ == "__main__":
  main()

I run this on my machine.
The problem is this script, with either method, always raises error:

Traceback (most recent call last):
File "./query.py", line 91, in <module>
  main()
File "./query.py", line 66, in main
  del someKind.someField
AttributeError: __delete__

The documentation ( http://code.google.com/intl/en/appengine/articles/update_schema.html ) said something like “use delattr to delete the obsolete property and then save the entity”. But there is no example what so ever.

How can I do this?
Was my steps correct?
How am I to delete the property?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:06:17+00:00Added an answer on May 15, 2026 at 11:06 am

    You can’t delete properties from a Model – every model instance has the same set of properties. Expando, however, allows you to have dynamic properties.

    The easiest path is probably this:

    1. Change your model class to extend db.Expando instead of db.Model
    2. Add the new property to the model class (use the ‘name’ keyword argument if you want to give it a different name in the datastore to what you access it with in Python) and remove the old one.
    3. Use the mapreduce API to iterate over every entity, calling “del mymodel.oldprop”, and setting the new property as appropriate.
    4. Update the model definition again, setting it back to extending db.Model.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a model like this class Foo(db.Model): id = db.StringProperty() bar
I have an existing schema: class Example (db.Model) : row_num = db.IntegerProperty(required=True) updated =
I have a model that looks like this: public class Book { public string
I have an existing data model. I would like to express this data model
I have an existing model for my project. I would like to switch to
I have a model that contains a collection, such as this: class MyModel {
Is it possible to chain metaclasses? I have class Model which uses __metaclass__=ModelBase to
Am using django forms on my app. I have a model Client like this:
I have an existing app that has many, many models. I'd like to log
I have a model Foo which have a ForeignKey to the User model. Later,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.