You are right.
I have tried, and it behaves the same way for me.
You can work around this issue by passing the key_name as initial data
to your form:

    form = TestForm(instance = entry, initial={'key_name': entry.key().name()})

It seems this is on purpose, the relevant code starts at line 803 in
google.appengine.ext.db.djangoforms:

      if instance is None:
        instance = opts.model(**converted_data)
        self.instance = instance
      else:
        for name, value in converted_data.iteritems():
          if name == 'key_name':
            continue
          setattr(instance, name, value)

Maybe the field should rather be removed from the form, then.

Best Regards,

Jesaja Everling


On Wed, Nov 26, 2008 at 10:35 AM, Denya <[EMAIL PROTECTED]> wrote:
> No, i mean a little bit another thing.
>
> When i open page with form and want to edit some data (it means that i
> create form by passing db entity instance) the input field key_name appears,
> but it is empty (in db it's not empty)
>
> I understand, that i can't edit this. But i want this to be not empty when i
> show edit form!
>
> On Tue, Nov 25, 2008 at 6:47 PM, Jesaja Everling <[EMAIL PROTECTED]>
> wrote:
>>
>> Hi Denis!
>>
>> Once you have an entity with a key_name, you cannot change the key_name.
>> That is the reason that the form doesn't use this field when using it
>> to change an entity.
>> If you want to hide it from an editing-form, you can either do so in
>> template logik by passing a variable like "change=True", or you can
>> make another form definition that excludes the field.
>> Do I understand you correctly that the key_name field doesn't appear
>> when you are editing an entity?
>>
>> would have to create a separate form for editing
>>
>> On Tue, Nov 25, 2008 at 7:33 AM, Denis Moskalets <[EMAIL PROTECTED]>
>> wrote:
>> >
>> > ext/db/djangoforms.py contains interesting description for some class:
>> >
>> >  If you define a form field named 'key_name' it will be treated
>> >  specially and will be used as the value for the key_name parameter
>> >  to the Model constructor. This allows you to create instances with
>> >  named keys. The 'key_name' field will be ignored when updating an
>> >  instance (although it will still be shown on the form).
>> >
>> > I've tried this. It's really works, key_name field appears. key_name
>> > properly saved into DB. It's really cool!
>> >
>> > But there only little problem. "The 'key_name' field will be ignored
>> > when updating an instance (__although it will still be shown on the
>> > form__)".
>> > key_name field doesn't appear at form, when you trying to edit data.
>> > I've read SDK code, and really... there nothing about filling key_name
>> > by data.
>> > In SDK source code, 'key_name' appears only in save() method.
>> >
>> > Is it really undocumented feature, that doesn't completely realised,
>> > or it is bug?
>> >
>> > >
>> >
>>
>>
>>
>> --
>> o
>> L_/
>> OL
>> This is Schäuble. Copy Schäuble into your signature to help him on his
>> way to Überwachungsstaat.
>>
>>
>
>
> >
>



-- 
o
L_/
OL
This is Schäuble. Copy Schäuble into your signature to help him on his
way to Überwachungsstaat.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to