On Wed, 2006-09-06 at 14:28 -0400, Jay Parlar wrote:
> Following James' tutorial
> (http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model)
> I created a UserProfile model, that is essentially:
> 
> class UserProfile(models.Model):
>     board_member = models.BooleanField()
>     user = models.OneToOneField(User)
> 
> 
> What I want is a list of Users, ordered by last_name, filtering on
> board_member=True.
> 
> I tried this:
> 
> User.objects.filter(get_profile__board_member=True), but this gives
> the following:
> 
> TypeError: Cannot resolve keyword 'get_profile' into field
> 
> 
> So I'm guessing that the filter syntax can't handle methods, just
> attribute fields.

That's correct, because we turn the keyword arguments in filter()
clauses into SQL directory (splitting them up into tables and columns).
There is no way to "shell out" to a Python function for the test.

> 
> So to fix this, I tried going the other direction, by filtering on
> UserProfile, and then ordering the results on User, doing this:
> 
> UserProfile.objects.filter(board_member=True).order_by('auth_user.last_name')
> 
> but I get this:
> 
> OperationalError: (1054, "Unknown column 'auth_user.last_name' in
> 'order clause'")

Why isn't this order_by('user.last_name'), since the name of the
attribute in UserProfile is 'user'? Is this just a typo?

Malcolm


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to