I am using the code shown below.  The part causing the problem is the
Role class which describes the role a person might have on a project.
As part of that role, I would have an attribute that records the start
and end date of the person's involvement.  The problem seems to be
coming when I make an ill-fated attempt to define a default start date
as the startdate of the project to which the role is linked.

---------------------code------------------------------------------
from django.db import models

class Project(models.Model):
    """class to describe the attributes that characterize a project"""

    #reference number for project
    referencenum = models.CharField("reference number for project",
                                                      max_length=20)
    #begin date of project
    startdate =  models.DateField()

class Role(models.Model):
    """class to describe a Person object's affiliation to a Project
object"""

    #project in which person is involved
    project =   models.ForeignKey(Project)

    #begin date of person's involvement on project; this is the
problem line
    rolestartdate = models.DateField(default = \
                                Project.objects.get
(pk=project.id).startdate)

-----------------------------------------------------------------
when I run:
      manage.py syncdb
I get the following error:

   rolestartdate = models.DateField(default = Project.objects.get
(pk=project.id).st
   artdate)
   AttributeError: 'ForeignKey' object has no attribute 'id'

I was under the impression that django creates an attribute on every
model, foo.id, that serves as a primary key.

Many thanks in advance to anyone who can explain what what I not
grasping here.

--

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