On Mon, 2009-05-18 at 17:12 -0700, neri...@gmail.com wrote:
> I have an Employee profile associated with Users who are staff, how do
> I return the associated user attributes from within the profile model
> i.e., 'full_name' from Users? Anytime I try to access the User
> attributes from within the profile class I get errors: Cannot resolve
> keyword 'full_name' into field.
> 
> class Employee(models.Model):
>         user = models.ForeignKey(User, unique=True)
>         phone = PhoneNumberField()
>         ssn = models.CharField(max_length=11)
>         address = models.CharField(max_length=50)
>         city = models.CharField(max_length=30)
>         state = USStateField(default='WA')
>         zip_code = models.CharField(max_length=10)
> 
>         def __unicode__(self):
>                 return self.user.full_name
> 
>         class Meta:
>                 ordering = ['last_name']

I'm assuming you are getting complaints about 'last_name'.

I think what you want is:

    class Meta:
        ordering = ['user__last_name']

Unless this is wrong, Options.ordering should probably only explain any
differences from order_by in the docs.

http://docs.djangoproject.com/en/1.0/ref/models/querysets/#order-by-fields

sdc



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

Reply via email to