tags:

views:

8

answers:

1

I can't seem to find a solution for the following in the django docs.

So for example, i have a field in Class table called department that points to Department database (foreignKey). If I create a admin interface for Class table called ClassAdmin(admin.ModelAdmin). Then i create an entry for Department class. Now automatically, when i try to create a new Class entry, it will show a dropdown menu for entries in Department. The problem arises when i try to do that, it would show something along the lines of "Department Object" for each entry in the dropdown. I would like a way to define canonical names for each entry for department (Department.name is the field i would like to use).

Does anyone know how to do that?

Thanks a lot!

+1  A: 

Implement the __str__ method in your Department model:

def __str__(self):
    return self.name
Aviral Dasgupta