Using ModelForm in inlineAdmin with view permissions

81 views
Skip to first unread message

the.one.abo...@gmail.com

unread,
Jan 1, 2022, 11:45:21 AM1/1/22
to Django users
Hello everyone!

I have created a demo project to convey my use case programmatically. Here is a brief description of the project.

The Django project contains an application "home" that has four models: Device, Location, FloorPlan and DeviceLocation. DeviceLocation is a thorough model that connects Device model to FloorPlan and Location using GenericForeignKey.

The "home" application registers ModelAdmin classes for Device, FloorPlan and Location models. An InlineAdmin is present for the DeviceLocation model which is added to DeviceAdmin (ModelAdmin class for Device model). DeviceLocationInlineAdmin uses a custom form (DeviceLocationForm) to display fields from related Location models.

Problem
If a staff user has view-only permission to all the models (Device, FloorPlan, Location and DeviceLocation), then the content of DeviceLocationForm shows empty.

Screenshot from 2022-01-01 22-08-00.png

After giving change permission to both Device and DeviceLocation model, the form starts showing information.

I don't understand if there's some logic in ModelAdmin that is removing this information.

Warm wishes for a new year,
Gagan Deep

the.one.abo...@gmail.com

unread,
Jan 3, 2022, 7:20:57 AM1/3/22
to Django users
Hi, 

My previous email did not include link to the demo project. Please find the demo project here: https://github.com/pandafy/inline_view_only

Thanks, 
Gagan Deep

Reply all
Reply to author
Forward
0 new messages