On 06/03/07, roberto <[EMAIL PROTECTED]> wrote:
>
> dear all,
>
> i'm starting to use django and i have what may seem to a lot of you
> the stupidest question ever, though i have not been able to solve
> this,.
>
> i have to classes:
>
> class warriors(models.Model):
>     username = models.CharField(maxlength=50)
>
> class warriors_gaming(models.Model):
>     warrior_id = models.OneToOneField(warriors)
>     points = models.IntegerField()
>
> what i'd like is to perform a sql query like:
>
> select * from warriors, warriors_gaming where warriors.id =
> warriors_gaming = warrior_id and warriors.username = 'me'
>
> the object i would result therefore would have all properties of both
> tables. i am trying with:
>
> warriors_info = warriors.objects.get(username__exact = "robbie")
>
> which works ok however warriors_info.points does not exist as method
> or property. no luck with:
>
> warriors_info = warriors_gaming.objects.get(warriors__username__exact
> = "robbie")
>
> which gives me an error stating that 'warrior' is unknown. tried with:
>
> warriors_list = warriors_gaming.objects.select_related()
>
> which works, however i cannot find a place where to set my username =
> 'me' clause. i am sure this must be pretty simple but cannot find a
> way to do this... hopefully some nice soul will help me out to get
> started.
>
> thank you in advance,
>
> r.
>
>

Go carefully trough the DB API documentation. You can chain your query
methods to form quite complex expressions.  Look at .filter()

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