Greeting all!

CAVEAT:  I'm a Django newbie. I've spent about 3 hours searching,
reading, hazing over all the documentation and tutorials and it's
quite likely I have missed it or I'm way too new to Django to
understand the simplicity of the solution for the problem I'm
presenting.  So, feel free to "RTFURL" (provided you provide the
URL :)  Okay, enough said.

The models.py from my app ("publications") is included at the end.  My
end goal is to get the following:  'published.title,
journal_names.name, journal_impact_factor.impact_factor'.

In standard SQL land, it would be something like:

SELECT published.title, journal_names.name,
journal_impact_factor.impact_factor
FROM published, journal_names, journal_impact_factor
WHERE
     published.journal_names_id=journal_names.id
     AND
     published.year=journal_impact_factor.year
     AND
     journal_impact_factor.journal_names_id=journal_names.id;

Now, I can get publication title and journal name via:
     latest_pubs_list = published.objects.all().order_by('-date')[:10]
     [ (p.title, p.journal_names.name) for p in latest_pubs_list]

But I'm stumped on how to bring in the
journal_impact_factor.impact_factor.  Ideas?  Maybe I've come about
the model construction from the wrong perspective (i.e. a pure PGSQL
as opposed to the "Django" way).  I don't know.  But I'd appreciate
any insight anyone could provide.

Oh yeah, if I've been too brief or you need more snippets, just let me
know!

Thanks!
-Tim

~~~~~ models.py
from django.db import models

# Create your models here.

class journal_names(models.Model):
     name = models.CharField(maxlength=80)
     citation = models.CharField(maxlength=80)

     class Admin:
          pass

     class Meta:
          verbose_name_plural = "journal_names"

class journal_impact_factor(models.Model):
     journal_names = models.ForeignKey(journal_names)
     year = models.PositiveSmallIntegerField()
     impact_factor = models.FloatField(max_digits=5, decimal_places=3)

     class Admin:
          pass

class published(models.Model):
     journal_names = models.ForeignKey(journal_names)
     title = models.CharField(maxlength=160)
     year = models.PositiveSmallIntegerField()

     class Admin:
          pass

     class Meta:
          verbose_name_plural = "published"


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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