Wednesday, February 23, 2011

admin list help

hi group. I really need to know how to do something in regard to my
models shown below. Please consider these three models and then look
at the bottom for my question.

garments
class modela (models.Model):
id = models.AutoField (primary_key=True)
type = models.CharField (max_length=128, blank=False)
order_id = models.IntegerField (blank=False)
lastSave = models.BigIntegerField (blank=True)

class modelaAdmin(admin.ModelAdmin):
list_display = ('id','type','order_id','lastSave')
search_fields = ['type','order_id','lastSave']
admin.site.register(modela,modelaAdmin)

orders
class modelb (models.Model):
id = models.AutoField (primary_key=True)
title = models.CharField (max_length=128, blank=False)
status = models.CharField(max_length=20, blank=False)
client_id = models.CharField(max_length=11, blank=False)
source = models.CharField (max_length=255, blank=False)

class modelbAdmin(admin.ModelAdmin):
list_display = ('id','title','status','client_id','source')
search_fields = ['title','status','client_id','source']
admin.site.register(modelb,modelbAdmin)


Customer
class modelc (models.Model):
id = models.CharField
(primary_key=True,max_length=10,blank=False)
firstName = models.CharField (max_length=128, blank=False)
lastName = models.CharField (max_length=128, blank=False)
phone = models.CharField (max_length=64, blank=False)
email = models.CharField (max_length=128, blank=False)
comments = models.TextField (blank=False)

class modelcAdmin(admin.ModelAdmin):
list_display =
('id','firstName','lastName','phone','email','comments')
search_fields =
['id','firstName','lastName','phone','email','comments']
admin.site.register(modelc,modelcAdmin)

I am looking to do two things:

1) in the admin list for modela, i would like to show the firstname
and lastname from modelc.

modela is tied to model by by modela.client_id=modelb.id and modelb
is tied to modelc by modelb.client_id=modelc.id

In addition, I would like to be able to search modela by
modelc.firstname or modelc.lastname


2) in the list view for modela, I would like to show lastSave as a
date/time value. The integer value stored in lastSave is the integer
value of a date.


Are these two things possible to do... if so, how do i do it?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate