On Mon, 2008-11-24 at 21:47 -0800, limas wrote:
> hai all,
> 
> i have say two tables:
> class Candidate(models.Model):
> 
>         first_name=models.CharField('First Name',max_length=30)
>         last_name=models.CharField('Last Name',max_length=30)
>         ......
>         owner=models.Foreign_key(User)
>         enter_by=models.ForeignKey(User,related_name="users")
> class User(models.Model):
>         user_name=models.CharField(max_length=30)
> 
> and i want show something like this in my form:
> <td><candidate.name></td>
> ........
> <td><user.created_by></td>
> 
> i tried with
> SORT_FIELD='users_owner__user_name'
> candidate=Candidate.objects.select_related().order_by(SORT_FIELD)
> but an error like "FieldError: Cannot resolve keyword 'users_owner'
> into field." is comming....

Your queryset is a set of Candidate objects and that model indeed does
not have a field called users_owner. Do you just mean "owner" perhaps?
Since you don't explain what you're hoping to see, it's tough to guess
the right answer here, but the error message is telling you the problem.
You are trying to order by a field that doesn't exist. "users_owner"
would make sense if you were working with a User model, but not on a
Candidate model.

Perhaps you are misunderstanding the use of related_name? What is the
problem you are trying to solve. In other words, what are you trying to
order the candidates by?

Regards,
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to