Yes, it appears the admin interface handles any models with a non auto-integer primary key poorly for create operations - in all cases it: * displays columns marked primary key as disabled when editing * doesn't display fields marked primary field on create, and leaves them to default on the database query it makes
Which will work fine for auto-integer keys, but not otherwise. Still I'm pretty impresses the admin interface can handle composite primary keys otherwise (for edit/delete), might have a look around at the SPROX code, as this limitation sounds solvable On Saturday, June 27, 2015 at 3:15:27 AM UTC+12, Alessandro Molina wrote: > > > > On Fri, Jun 26, 2015 at 4:47 PM, Alessandro Molina <[email protected] > <javascript:>> wrote: > >> >> however the interface only allow me to edit and delete records, not >>> create new ones. (This is true for any non auto-integer primary key, not >>> just multi column ones) >>> >> >> What do you mean regarding that it doesn't allow to create new records? >> What does it happen? >> > > Ok, just saw what's your problem. > Looks like most of SPROX code is meant to work with composite primary keys > in relations, but the form generation part doesn't support composite > primary keys. > > Both EditableForm and AddRecordForm actually rely on get_primary_field > method of the provider, which in case of multiple primary keys only returns > the first. > So both of them actually consider only the first field to be the primary > key and the second one as a plain field. > > This leads to odd behaviours, like in case of edit you can only change the > second field of the primary key and in case of new the first field is > missing at all as it is considered to be automatically generated. > > I suppose New works only if you provide a default value for both fields, > as it expects the primary key to be automatic. > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

