Monday, January 3, 2022

Re: Using ModelForm in inlineAdmin with view permissions

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

On Saturday, January 1, 2022 at 10:15:21 PM UTC+5:30 the.one.abo...@gmail.com wrote:
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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6a73126d-c39a-43c1-af92-f32ff8ada22an%40googlegroups.com.

No comments:

Post a Comment