On Tuesday, October 7, 2014 2:16:53 PM UTC+5:30, Sachin Tiwari wrote:
>
> Hi,
>
> I added an extra field phone number in existiing user model and now I
> tyring to access that field by below method,
>
> UserAdmin.list_display = ('email', 'first_name', 'last_name','is_staff',
> SMSRegistration.phone_no)
>
> type object 'SMSRegistration' has no attribute 'phone_no'
>
>
> Please help.
>
>
Hi Collin,
Thanks for your kind support,
I tried follwing ways but it did not work,
class UserAdmin(UserAdmin):
inlines = (EmployeeInline, )
#UserAdmin.list_display = ('email', 'first_name',
'last_name','is_staff',SMSRegistration.phone_no)
list_display = ('email', 'first_name',
'last_name','is_staff','phone_no')
#list_display = ('email', 'first_name',
'last_name','is_staff','phone_no')
#list_display = UserAdmin.list_display + ('phone_no',)
def phone_no(self, SMSRegistration):
#return User.SMSRegistration.phone_no
return SMSRegistration.phone_no
If I used below line, It will show smsregistration option but phone number
would not be dispalyed.
UserAdmin.list_display = ('email', 'first_name',
'last_name','is_staff',SMSRegistration)
I am sharing my smsregistartion class also,
class SMSRegistration(models.Model):
user = models.OneToOneField(User)
phone_no = models.IntegerField(max_length=10,blank=False,null=False)
--
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 [email protected].
To post to this group, send email to [email protected].
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/8bb9d2ea-b05b-463f-9b3f-f065dba362c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.