Hi,

i'm new to django and i've met with some problems when i'm trying to
display custom fields in the change user admin page. Hope some of u
can help me out.

1) I've a country table which is linked the user profile table that i
created as below.

-------------------------------------------------------------------------------------------------

class Country(models.Model):
    country_id = models.AutoField(primary_key=True)
    iso = models.CharField(max_length=2)
    name = models.CharField(max_length=80)
    iso3 = models.CharField(max_length=3)
    numcode = models.PositiveSmallIntegerField()
    class Meta:
        db_table = 'country'


class UserProfile(models.Model):
    user = models.ForeignKey(User, primary_key=True)
    country = models.ForeignKey(Country)

    class Meta:
        db_table = 'user_profile'

-------------------------------------------------------------------------------------------------

2) I've added the field into the change user page by adding the
following

-------------------------------------------------------------------------------------------------

from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from mafia.profile.models import UserProfile,Country

admin.site.unregister(User)

class UserProfileInline(admin.StackedInline):
        model = UserProfile

class UserProfileAdmin(UserAdmin):
        inlines = [UserProfileInline]

admin.site.register(User, UserProfileAdmin)

-------------------------------------------------------------------------------------------------

When i view the change user page, my country field is displayed as a
drop down box as intended, but the contents of the drop down box is
the "Country Object" instead of my intention to display the name of
the country.

I've been trying to solve this problem for a few hours now by googling
and tweaking the templates but not successful. Can anyone enlighten me
in where i went wrong?

Regards
Jian Xiong

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to