Hello all,

I am new to django, please excuse any naivity. I would like to list
child and related parent records from the scenario below. Although
quite happily displaying ChildFile records, I can't seem to display
any ParentFile records.


models.py
class ParentFile(models.Model):
    recnum = models.AutoField(primary_key=True)
    number = models.FloatField(max_digits=12, decimal_places=0)
    date = models.DateField()
    time = models.CharField(maxlength=5)
    city = models.CharField(maxlength=40)
    country = models.CharField(maxlength=40)
    ...

class ChildFile(models.Model):
    docket = models.ForeignKey(ParentFile, related_name = 'number',
unique=True)
    recnum = models.TextField(unique=True) # This field type is a
guess.
    docket = models.FloatField(max_digits=12, decimal_places=0,
primary_key=True)
    name = models.CharField(maxlength=40)
    date = models.DateField()
    ...

views.py
def Outstanding(request):
    fLatestRecs = ChildFile.objects.filter(name =
'DAN').select_related().order_by('-date')
    return render_to_response('/report.html', {'fLatestRecs':
fLatestRecs })


report.html
...
{% if fLatestRecs %}
        <table border="1" cellspacing="0" cellpadding="0"
width="100%">
                    <tr bgcolor="lightblue">
                        <td>Date</td>
                        <td>Time</td>
                        <td>Name</td>
                        <td>City</td>
                        <td>Country</td>
                    </tr>
            {% for ChildFile in fLatestRecs %}
                    <tr bgcolor="lightblue">
                        <td>{{ ChildFile.date }}</td>
                        <td>{{ ChildFile.time }}</td>
                        <td>{{ ChildFile.name }}</td>
                        <td>{{ ParentFile.city }}</td>
                        <td>{{ ParentFile.country }}</td>
                    </tr>
            {% endfor %}

        </table>
{% else %}
    <p>No Records available.</p>
{% endif %}

Any help would be much appreciated.
Many thanks,
Eamon

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