I'm reading the tutorial here, for Django 1.6: https://docs.djangoproject.com/en/1.6/intro/tutorial01/
and it uses the attribute choice_set
, which I don't recognize. I thought this was the decapitalized child object (which was formed using ForeignKey
as described earlier in the tutorial), but this yields an error when I try this myself. Is my assumption correct?
I know I'm not being the most concise, so just ask if you need further clarification.
Here is my models.py
:
from django.contrib.auth.models import User
class Information(models.Model):
title = models.CharField(max_length = 200)
body = models.TextField()
date = models.DateTimeField()
def __unicode__(self):
return self.title
class InformationChild(models.Model):
information = models.ForeignKey(Information)
child_text = models.CharField(max_length = 200)
def __unicode__(self):
return self.child_text
This is what I attempted:
i1 = Information.objects.filter(pk=1)
i1.informationchild_set.all()
This should return an empty list according to the tutorial, as I haven't set any children to the parent. If I'm understanding this correctly at all, that is.