Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2019-01-15 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+-
 Reporter:  Sebastian Noack  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => duplicate


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.0e24248fffd84b7fa8e483acd41773c3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2019-01-15 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  Sebastian Noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+

Comment (by Olivier):

 I think this is a duplicate of https://code.djangoproject.com/ticket/27967
 (which is fixed)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.eaa8aef165064a12a7638414406907eb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2017-11-06 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  Sebastian Noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+
Changes (by Andi Albrecht):

 * cc: Andi Albrecht (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.c7d870530c3051676d914015161a89c2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2016-11-15 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  Sebastian Noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+
Changes (by Tim Graham):

 * needs_better_patch:  0 => 1


Comment:

 As noted on the PR, the fix allows data corruption in some cases.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.d1c2b5e51f37dce17ef1bafdf1d0a514%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2016-10-13 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  Sebastian Noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Tim Graham):

 * needs_better_patch:  1 => 0


Comment:

 [https://github.com/django/django/pull/7365 New PR]

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.72fb18fa2fd35d827f4c00841b00216b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2016-08-17 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  sebastian_noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+
Changes (by timgraham):

 * needs_better_patch:  0 => 1


--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.054c9080f96d761434d404f7ab475d38%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2016-07-22 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  sebastian_noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by timgraham):

 * needs_tests:  1 => 0


Comment:

 [https://github.com/django/django/pull/6818 PR]

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.5cb663aef12243bf5088af63c3f13919%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2016-07-22 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  sebastian_noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by timgraham):

 I closed #26934 as a duplicate.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.eab9a119737ff43ec5198d173650820c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2016-06-20 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  sebastian_noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by olivierdalang):

 * has_patch:  0 => 1
 * needs_tests:  0 => 1


Comment:

 I had a look at the source. I see two places where this can be fixed :

 A. in django/db/models/base.py

 Model inheritance is created using OneToOneField but doesn't set the field
 to editable=False.
 This seems wrong, but at the same time, it seem to be consistent with
 regular primary keys, that for some reason don't set editable=False
 neither.
 The fix consists of settings editable=False on those fields.
 I'm not sure of the consequences of this, but this breaks potentially a
 lot of things.

 
https://github.com/olivierdalang/django/commit/a4ea0a021b784c5fbbecebed01f86c3987f1a8e9

 B. in django/contrib/admin/helpers.py

 There's a needs_explicit_pk_field() method which is exactly for that.
 The fix B consists of return True if the primary key is a OneToOneField.
 I guess this has much less consequences and is much safer.

 
https://github.com/olivierdalang/django/commit/fed7cd7f73f06a26f8a2eb8e867bdf4c81d4ae00


 What do you think ? For which fix should I open a PR ? Is there any chance
 this gets backported to 1.9 ?

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.5acd105ef344d3640d994b85fee109d2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2016-06-20 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  sebastian_noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by olivierdalang):

 * cc: olivier.dalang@… (added)


Comment:

 I agree it's kind of tricky when the user can change the ID (as expeced
 behaviour is not clear), but the issue also happens in a very normal case,
 simply when one is using UUIDs instead of regular autoincremented IDs :

 {{{
 #!python
 from django.db import models
 import uuid

 class Event( models.Model ):
 id = models.UUIDField(primary_key=True, default=uuid.uuid4)
 name = models.CharField(max_length=10, blank=False)

 def __str__(self):
 return self.name

 class Person( models.Model ):
 id = models.UUIDField(primary_key=True, default=uuid.uuid4)
 parent = models.ForeignKey('Event', null=True, blank=True,
 related_name='children')
 name = models.CharField(max_length=10, blank=True)

 def __str__(self):
 return self.name

 class Visitor(Person):
 pass
 }}}

 {{{
 #!python
 from django.contrib import admin
 from .models import Event, Visitor

 class VisitorInline( admin.TabularInline ):
 model = Visitor
 show_change_link = True


 class EventAdmin( admin.ModelAdmin ):
 inlines = [VisitorInline,]


 admin.site.register(Event, EventAdmin)
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.55d25ba7e76cd57ab2df88539cb4662c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2015-10-09 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
-+
 Reporter:  sebastian_noack  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  contrib.admin|  Version:  1.2
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by timgraham):

 This remains an issue as of 7a5b7e35bf2e219225b9f26d3dd3e34f26e83e9c
 (Django 1.10.dev).

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.d9b3625cb15fff3177a2ca9270d4a2d8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2011-06-10 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
---+---
   Reporter:  sebastian_noack  |  Owner:  nobody
   Type:  Bug  | Status:  new
  Milestone:   |  Component:  contrib.admin
Version:  1.2  |   Severity:  Normal
 Resolution:   |   Keywords:
   Triage Stage:  Accepted |  Has patch:  0
Needs documentation:  0|Needs tests:  0
Patch needs improvement:  0|  Easy pickings:  0
  UI/UX:  0|
---+---
Changes (by dArignac):

 * ui_ux:   => 0
 * easy:   => 0


Comment:

 Looks like an duplicate of #13696

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2011-04-20 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
---+-
   Reporter:  sebastian_noack  |Owner:  nobody
   Type:  Bug  |   Status:  new
  Milestone:   |Component:  contrib.admin
Version:  1.2  | Severity:  Normal
 Resolution:   | Keywords:
   Triage Stage:  Accepted |Has patch:  0
Needs documentation:  0|  Needs tests:  0
Patch needs improvement:  0|
---+-

Comment (by lukeplant):

 Probably related: #2259

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2011-04-20 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
---+-
   Reporter:  sebastian_noack  |Owner:  nobody
   Type:  Bug  |   Status:  new
  Milestone:   |Component:  contrib.admin
Version:  1.2  | Severity:  Normal
 Resolution:   | Keywords:
   Triage Stage:  Accepted |Has patch:  0
Needs documentation:  0|  Needs tests:  0
Patch needs improvement:  0|
---+-

Comment (by sebastian_noack):

 I was able to work around that issue and make the objects from the inline
 admin editable including their primary key by following hack. It deletes
 all objects and re-adds them again. In my opinion django must support that
 case by default. But maybe their is a better way as first removing all
 objects.

 {{{
 #!python
 from django.contrib import admin
 from django.db import transaction

 class SuperAdmin(admin.ModelAdmin):
 inlines = [SubSubInline]

 def save_model(self, *args, **kwargs):
 super(SuperAdmin, self).save_model(*args, **kwargs)
 self._saved = True

 def change_view(self, request, *args, **kwargs):
 if request.method != 'POST':
 return super(SuperAdmin, self).change_view(request, *args,
 **kwargs)

 transaction.enter_transaction_management()
 transaction.managed(True)

 # ModelAdmin.change_view is decorated with autocommit. So we
 # have to lazy patch the transaction API in order to bypass
 # transaction management from within ModelAdmin.change_view.
 # So we can rollback the transaction afterwards if needed.
 transaction_api = (transaction.enter_transaction_management,
transaction.leave_transaction_management,
transaction.commit, transaction.rollback)

 transaction.enter_transaction_management = lambda *args, **kwargs:
 None
 transaction.leave_transaction_management = lambda *args, **kwargs:
 None
 transaction.commit   = lambda *args, **kwargs:
 None
 transaction.rollback = lambda *args, **kwargs:
 None

 try:
 for inline in self.inline_instances:
 prefix = inline.get_formset(request).get_default_prefix()

 request.POST = request.POST.copy()
 request.POST[prefix + '-INITIAL_FORMS'] = '0'

 inline.queryset(request).delete()

 return super(SuperAdmin, self).change_view(request, *args,
 **kwargs)
 finally:
 (transaction.enter_transaction_management,
  transaction.leave_transaction_management,
  transaction.commit, transaction.rollback) = transaction_api

 if getattr(self, '_saved', False):
 del self._saved
 transaction.commit()
 else:
 transaction.rollback()
 transaction.leave_transaction_management()
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2011-04-20 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
---+-
   Reporter:  sebastian_noack  |Owner:  nobody
   Type:  Bug  |   Status:  new
  Milestone:   |Component:  contrib.admin
Version:  1.2  | Severity:  Normal
 Resolution:   | Keywords:
   Triage Stage:  Accepted |Has patch:  0
Needs documentation:  0|  Needs tests:  0
Patch needs improvement:  0|
---+-
Changes (by lukeplant):

 * stage:  Unreviewed => Accepted


Comment:

 Accepted on the basis that we should do something better than crash. What
 exactly to do is tricky - it is similar to the case of editing the primary
 key value, which can result a new row rather than a changed row, IIRC.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2011-04-01 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
---+-
   Reporter:  sebastian_noack  |Owner:  nobody
   Type:  Bug  |   Status:  new
  Milestone:   |Component:  contrib.admin
Version:  1.2  | Severity:  Normal
 Resolution:   | Keywords:
   Triage Stage:  Unreviewed   |Has patch:  0
Needs documentation:  0|  Needs tests:  0
Patch needs improvement:  0|
---+-
Changes (by anonymous):

 * needs_better_patch:   => 0
 * component:  Database layer (models, ORM) => contrib.admin
 * needs_tests:   => 0
 * needs_docs:   => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2011-04-01 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
---+-
   Reporter:  sebastian_noack  |Owner:  nobody
   Type:  Bug  |   Status:  new
  Milestone:   |Component:  contrib.admin
Version:  1.2  | Severity:  Normal
 Resolution:   | Keywords:
   Triage Stage:  Unreviewed   |Has patch:  0
Needs documentation:  0|  Needs tests:  0
Patch needs improvement:  0|
---+-
Changes (by anonymous):

 * needs_better_patch:   => 0
 * component:  Database layer (models, ORM) => contrib.admin
 * needs_tests:   => 0
 * needs_docs:   => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #15665: Inline admins are broken when primary key is not an AutoField and not editable.

2011-03-23 Thread Django
#15665: Inline admins are broken when primary key is not an AutoField and not
editable.
--+---
 Reporter:  sebastian_noack   | Owner:  nobody
   Status:  new   | Milestone:
Component:  Database layer (models, ORM)  |   Version:  1.2
 Keywords:|  Triage Stage:  Unreviewed
Has patch:  0 |
--+---
 For each inline object, a hidden field for its primary key (if it is an
 AutoField) is included in the form. But if you inherit from a concrete
 model that has a custom (not AutoField) primary key, you end up in a
 situation where you have a primary key which is a OneToOneField that is
 not editable in the admin.

 {{{
 #!python
 from django.db import models

 class Event(models.Model):
 name = models.CharField(max_length=100, primary_key=True)

 def __unicode__(self):
 return self.name

 class Person(models.Model):
 name = models.CharField(max_length=100, primary_key=True)

 def __unicode__(self):
 return self.name

 class Visitor(Person):
 event = models.ForeignKey(Event)

 def __unicode__(self):
 return u"'%s' at '%s'" % (self.person_ptr, self.event)
 }}}

 {{{
 #!python
 from django.contrib import admin

 class VisitorInline(admin.StackedInline):
 model = Visitor

 class EventAdmin(admin.ModelAdmin):
 inlines = [VisitorInline]

 admin.site.register(Event, EventAdmin)
 }}}

 In that case there is no element in the form that holds the primary key
 and you get the Exception below, when you try to save an existing object
 in the admin.

 {{{
 Traceback (most recent call last):

   File
 "/home/sebastian/djacap/fam/src/famtest/django/core/servers/basehttp.py",
 line 280, in run
 self.result = application(self.environ, self.start_response)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/core/servers/basehttp.py",
 line 674, in __call__
 return self.application(environ, start_response)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/core/handlers/wsgi.py",
 line 241, in __call__
 response = self.get_response(request)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/core/handlers/base.py",
 line 141, in get_response
 return self.handle_uncaught_exception(request, resolver,
 sys.exc_info())

   File
 "/home/sebastian/djacap/fam/src/famtest/django/core/handlers/base.py",
 line 165, in handle_uncaught_exception
 return debug.technical_500_response(request, *exc_info)

   File "/home/sebastian/djacap/fam/src/famtest/django/views/debug.py",
 line 58, in technical_500_response
 html = reporter.get_traceback_html()

   File
 "/home/sebastian/djacap/fam/src/famtest/django/core/handlers/base.py",
 line 100, in get_response
 response = callback(request, *callback_args, **callback_kwargs)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/contrib/admin/options.py",
 line 239, in wrapper
 return self.admin_site.admin_view(view)(*args, **kwargs)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/utils/decorators.py", line
 76, in _wrapped_view
 response = view_func(request, *args, **kwargs)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/views/decorators/cache.py",
 line 69, in _wrapped_view_func
 response = view_func(request, *args, **kwargs)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/contrib/admin/sites.py",
 line 190, in inner
 return view(request, *args, **kwargs)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/utils/decorators.py", line
 21, in _wrapper
 return decorator(bound_func)(*args, **kwargs)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/utils/decorators.py", line
 76, in _wrapped_view
 response = view_func(request, *args, **kwargs)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/utils/decorators.py", line
 17, in bound_func
 return func(self, *args2, **kwargs2)

   File "/home/sebastian/djacap/fam/src/famtest/django/db/transaction.py",
 line 299, in _commit_on_success
 res = func(*args, **kw)

   File
 "/home/sebastian/djacap/fam/src/famtest/django/contrib/admin/options.py",
 line 890, in change_view
 queryset=inline.queryset(request))

   File "/home/sebastian/djacap/fam/src/famtest/django/forms/models.py",
 line 705, in __init__
 queryset=qs)

   File "/home/sebastian/djacap/fam/src/famtest/django/forms/models.py",
 line 429, in __init__
 super(BaseModelFormSet, self).__init__(**defaults)

   File "/home/sebastian/djacap/fam/src/famtest/django/forms/formsets.py",
 line 47, in __init__
 self._construct_forms()

   File "/home/sebastian/djacap/fam/src/famtest/django/forms/formsets.py",
 line 97, in _construct_forms
 self.forms.append(self._construct_form(i))

   File "/home/sebastian/djacap/fam/src/famtest/django/forms/models.py",
 line 718, in _construct_form