#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: <https://code.djangoproject.com/ticket/15665#comment:9>
Django <https://code.djangoproject.com/>
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.

Reply via email to