title: What's the best way to specify a key_name for App Engine NDB Model?
body: <p>I'm trying to create an ndb model where each record has an unique field "name". I would like to define this field as the key_name field and use it to look up the records. Do I have to include a name field or can I somehow set the key_name field to an arbitrary string that the user can specify as long as it's unique?</p>
  
  <p>I'm thinking of using Model.get_or_insert to make sure that old records don't get overwritten, but is there a way to tell if the return value is newly created or pre-existing? I want to be able to display an error message if the user entered a duplicate name.</p>
  
  <p>Lastly, I tried to create a key_name field on a DjangoForms model that uses the above ndb model as the metaclass so I can use djangoforms for validation/rendering but for some reason my defined fields don't show up.</p>
  
  <p>class UserProfileForm(djangoforms.ModelForm):
      key_name = djangoforms.StringProperty()
      class Meta:
          model = UserProfile</p>