Hi David! 

Thanks for double checking my work. Yes, I also see those errors in the 
admin. I was guessing that those were related to the primary key issue. 

- 
Gagan Deep 

On Tuesday, November 22, 2022 at 12:03:28 PM UTC+5:30 
shang.xia...@gmail.com wrote:

> Hi Gagan,
>
> Interesting quirk you've found there, it's possible it could be a bug 
> though further digging may be required.
>
> A couple of interesting notes I found while fiddling with your example 
> code:
>
>    - If you press "Save and continue editing" there are unspecified form 
>    errors
>    - Setting `editable=False` on the token key fixes these unspecified 
>    errors and also allows you to delete the token
>    - Note that while inline works with `editable=False` it also means 
>    that you can't create a disabled token because of the nature of how 
>    checkboxes are handled. This is a separate issue.
>
>
> David
>
> On Tue, 22 Nov 2022 at 04:42, Gagan Deep <the.one.abo...@gmail.com> wrote:
>
>> Hello everyone! 
>>
>> In my project, I have created a model (Token) which uses a custom primary 
>> key (i.e. it uses a field defined by the model for the primary key instead 
>> of using "id"). I created an InlineAdmin class for this model and added the 
>> primary key field to InlineAdmin.readonly_fields. This InlineAdmin is added 
>> to ModelAdmin.inlines of another model.
>>
>> After making these changes, it is *not possible* to delete a Token 
>> object from the InlineAdmin (web interface). After selecting the delete 
>> checkbox for the Token object and clicking on the "Save and continue" 
>> button (of ModelAdmin), the page reloads with the Token object still there. 
>>
>> I have created a simple Demo project to replicate this issue,  
>> https://github.com/pandafy/inline_admin_pk_bug.  
>>
>> I have done some initial debugging, and found that when the primary key 
>> is added to the InlineAdmin.readonly_fields, an HTML input element for that 
>> field is not created. 
>>
>> This does not occur when a model has "id" field for the primary key and 
>> the "id" field is added to InlineAdmin.readonly_fields. 
>>
>> [image: Screenshot from 2022-11-21 23-05-22.png]
>>
>> I believe this is inconsistent behaviour. I will be more than happy to 
>> open an issue for this on Trac and work on a potential fix if this is a 
>> bug. 
>>
>> Regards, 
>> Gagan Deep 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/85d9b570-d3dc-46ca-8976-8ffcff061c01n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-developers/85d9b570-d3dc-46ca-8976-8ffcff061c01n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/49d2bd1e-7adc-49a9-bff6-a8f873ee686cn%40googlegroups.com.

Reply via email to