list_display can use functions as their value... so, you can have: class Employee(models.Model): sub_dept = ForeignKey(SubDept)
def company(self): return sub_dept.dept.company def dept(self): return sub_dept.dept class Admin: list_display = ('first_name, 'last_name', 'company', 'dept', 'sub_dept') On Aug 1, 3:16 pm, Rohit <[EMAIL PROTECTED]> wrote: > Actually my question is two fold, most likely due to brain farts on my > end. I'm relatively a newbie to Django, so please bear with me. > > Here's my scenario. I have this for my relationships: > Company->Dept->Sub-Dept->Employees->Roles > "->" represents a one-to-many relationship. > > Problem #1: > > If I do something like this: > Class Company(models.Model): > name... > > Class Dept(models.Model): > company = ForeignKey(Company) > name... > > Class Sub-Dept(models.Model): > dept = ForeignKey(Dept) > name... > > Class Employee(models.Model): > sub-dept = ForeignKey(Sub-Dept) > first_name... > > Class Admin: > list_display = ( 'first_name', 'last_name', 'sub-dept', ) > > The problem is when I go into the admin screen and view employees, > there is no way of displaying the company and dept. info next to the > name of the employee. How can I accomplish that? > > Problem #2: > This kinda arises from my efforts trying to fix Problem #1. > > I changed my code like so: > > ..... > ..... > Class Employee(models.Model): > company = ForeignKey(Company) > dept = ForeignKey(Dept) > sub-dept = ForeignKey(Sub-Dept) > first_name... > > Class Admin: > list_display = ( 'first_name', 'last_name', 'company', 'dept', > 'sub-dept', ) > > Now the problem is when I add an employee, I have to add some kind of > validation to the admin interface that checks whether the sub-dept, > dept and company match. My main issue is where can I add this > validation so that it is reflected in the admin interface? > > Thanks in advance for the pointers. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---