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

2014-10-24 Thread Collin Anderson
Hello Vittorio,

They don't seem bigger to me, but you should be able to change that by 
including custom CSS.

Collin

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5f775df7-f12d-4248-a2ca-2160762f0698%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2014-10-23 Thread Victor
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
>> 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0FE333F3-7AC4-46AB-8760-18124FB6153E%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


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

2014-10-21 Thread Vittorio
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
> 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/66CAAEC2-9C17-43F8-8915-24AC69FFE43B%40de-martino.it.
For more options, visit https://groups.google.com/d/optout.


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

2014-10-21 Thread Collin Anderson
oops readonly_field should be readonly_field*s*

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1b01a776-8dfb-4ae0-8309-3f86149608a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2014-10-21 Thread Collin Anderson
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

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d0ccb15e-c57f-4ab5-a3fd-44457e2411b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inserting further fields of a foreignkey object into change list view

2014-10-21 Thread Vittorio
Dear Experts,
Under Django 1.7 I have, among other things, the following:


### models.py
class Patients(models.Model):
surname = models.CharField(max_length=60, db_index=True)
name = models.CharField(max_length=60,  db_index=True)
address = models.CharField(max_length=150)
city = models.CharField(max_length=120)
zipcode = models.CharField(max_length=15)
def __unicode__(self):
return u"%s %s" % (self.surname, self.name)
class Meta:
db_table = u'patients'
ordering=['surname', 'name']

class Operation(models.Model):
date_of_operation=models.DateTimeField(db_index=True)
patient=models.ForeignKey(Patients,default=1)
class Meta:
db_table = u'operation'
verbose_name_plural = "Warehouse IN/OUT"
ordering=['-date_of_operation']

class Details(models.Model):
type = models.ForeignKey(Operation)
item_description = models.CharField(maxlength=100)
class Meta:
db_table = u'details'

### admin.py

class DetailsInline(admin.TabularInline):
fields = ('type','item_description')
model=Details

class DetailsOption(admin.ModelAdmin):
list_per_page = 500
list_display = ('type', 'item_description')
fields=(('type', 'item_description'))

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


Now, focusing on Operation and its inline DetailsInline, when I go to the admin 
change list view I see on top the date_of_operation field and the surname and 
name of the patient (as specified in the def unicode) followed by the 
change list of all Items description (as tabularinline) of that specific 
operation.

Now I would like to have on top of the admin change list view besides the 
surname and name of the patient also the address, city, zipcode of that 
patient. As you can see these pieces of info are fields of the table used as 
ForeignKey (see model Patients).

What is the quickest and neat way of getting this result?

Ciao
Vittorio



-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/096D8757-913D-4A2F-AD28-BA0F0364F3A7%40de-martino.it.
For more options, visit https://groups.google.com/d/optout.