Thanks for the reply! I probably didn't explain the problem properly. I have been using the ModelAdmin.readonly_fields option, however it hasn't been doing quite what I need for inline formsets. In the case of my inline form, when I set some of the fields to readonly, they end up read only for all forms in the formset. That is, every new row that's added to the inline formset and all existing ones end up with read only fields. What I was hoping to do was override a method to dynamically set some fields as read only, but only for some of the forms in the inline formset, not all of them.
The following code means that once a row/form in the inline was not created by the request.user, all rows/forms become readonly. What I'd like is to have fields only in the rows they did not create be readonly, leaving the ones that they did create editable. I wasn't sure whether there was perhaps an easy way to loop through the forms in the inline formset and set options in the admin for each of them separately. class IssuesInline(admin.TabularInline): model = Issues extra = 0 can_delete = False fields = ('risk', 'issue', 'priority', 'l1', 'c1', 'notes') exclude = ('added_by', 'modified_by') readonly_fields = ('lbyc') def get_readonly_fields(self,request,obj=None): if request.user.username!=obj.added_by: return ('risk', 'issue', 'priority', 'l1', 'c1', 'notes',) + self.readonly_fields return self.readonly_fields Thanks again! On Jan 20, 8:24 pm, Thomas <tho...@googlemail.com> wrote: > Am 20.01.2011 um 03:27 schrieb Peter Phillips: > > > Hello, > > > Is there a straightforward way to set fields to read only for a subset > > of the forms in an inline formset in the Admin? I'd like to set some > > fields to read only on my inline form for rows that were not created > > by the user. However, when I set the fields to read only, it of course > > affects all rows/forms in the inline, preventing the user from editing > > their own rows. Do I need to do a custom formset for > > InlineModelAdmin.formset? > > hi, > > maybe this provides a proper solution for > you:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri... > > good luck, > TR > > ------------------------------------------------ > > http://thoreg.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.