On Mon, Mar 9, 2009 at 7:24 AM, guptha <gjango...@gmail.com> wrote:

>
> thanks for your reply
> but i cannot solve my problem i will make my question clear this time
>
>
> class BankerCategory(models.Model):
>    name = models.CharField(max_length=125,unique=True)
>     created_on = models.DateTimeField(auto_now_add=True)
>
>
>
>
>
> class Banker(models.Model):
>    name = models.CharField(max_length=125,unique=True)
>     company_name = models.CharField(max_length=125,unique=True)
>     bankercategory = models.ForeignKey(BankerCategory)
>
>
>
>
>
>
> class Homeloan(models.Model):
>     LOAN_TYPE_CHOICES = (
>                            ('X', 'Fixed'),
>                            ('O','FLOATING'),
>                         )
>
>    banker = models.ForeignKey(Banker)
>    loan_type = models.CharField(max_length=1,
> choices=LOAN_TYPE_CHOICES)
>    loan_desc = models.TextField()
>
>    five_year_period_roi = models.FloatField()
>    five_year_period_emi = models.IntegerField()
>    isprivate = models.BooleanField()
>    ispublic = models.BooleanField()
>
>
>
>
> First i need to filter Homeloan based on 'loan_type' i.e.  fixed or
> floating
> then
> i need to display  all the fields of  Homeloan based on
> BankerCategory 'name'
> Suppose I have BankerCategory name fields as
> 1.Bank
> 2.Finance
> I need to display
>
>
>  loan_type:Fixed
>
> Bank
> ...
> ..
>
> Finace
> ...
> ...
>
>
>
>
> loan_type:Floating
>
>  Bank
> ...
> ..
>
> Finace
> ...
> ...
>
>
>
>
>
>
>
>
>
>
>
> On Mar 9, 4:00 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
> wrote:
> > On Mon, 2009-03-09 at 03:54 -0700, guptha wrote:
> > > hi gp,
> > > In models.py
> >
> > >       class BankerCategory(models.Model):
> > >               name = models.CharField(max_length=125,unique=True)
> >
> > >       class Banker(models.Model):
> > >                 bankercategory = models.ForeignKey(BankerCategory)
> >
> > >       class Homeloan(models.Model):
> > >                 banker = models.ForeignKey(Banker)
> >
> > > I need to retrieve 'name' field of 'BankerCategory' with 'Homeloan'
> > > object
> > >        home=Homeloan.objects.all()
> > >     from this 'home' object how can i access value of 'name' field of
> > > 'BankerCategory'
> >
> > Each Homeloan intsance has a "banker" attribute. You just access it to
> > refer to the related object. Seehttp://
> docs.djangoproject.com/en/dev/topics/db/queries/#related-objects
> > for all the details.
> >
> > Regards,
> > Malcolm
> >
>
Are you talking about accessing the value, or filtering on it.  For
filtering you want this:
http://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationshipsfor
attribute access you just follow what Malcolm suggested.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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