Thursday, October 23, 2014

Re: [AGAIN] Inserting further fields of a foreignkey object into change list view

Dear Experts,
following the indications of Collin I was able to see the extra fields I wanted to show in the change list view. But there's a little problem.
The character size of the labels of the readonly_fields are bigger than those of the printed fields so that the visual effect is that the labels and their relating fields don't look aligned (see the attached png file).
How can I modify the size of readonly_fields characters?
Ciao
Vittorio

Il giorno 21/ott/2014, alle ore 19:24, Vittorio ha scritto:

Great, it works!
Thanks a lot Collin
Ciao from Rome
Vittorio
Il giorno 21/ott/2014, alle ore 18:00, Collin Anderson ha scritto:

Hi Vittorio,

Would this work?

class OperationAdmin(admin.ModelAdmin):
   list_display = ('patient','date_of_operation') 
   fields = ('patient', 'patient_address', 'patient_city_zip', 'date_of_operation')
   readonly_field = ['patient_address', 'patient_city_zip']
   inlines= [DetailsInline]
   order_by= ['-date_of_operation']

   def patient_address(self, operation):
       return operation.patient.address

   def patient_city_zip(self, operation):
       return '%s %s' % (operation.patient.city, operation.patient.zipcode)

Collin

No comments:

Post a Comment