Thanks for the reply. I'm not new to Python so much as I'm overwhelmed
fairly often by all the jargon, but I'm wading my way through it.
Thanks for the link.

I added the import as you suggested to my model and for some reason
I'm still getting the error. I'll post my model in it's entirety,
which hopefully adds some more insight but I doubt anything else is
relevant.

from django.db import models
from projects.models import Project, Location
from users.models import User

class AlphaEvent(models.Model):
        project =                       models.ForeignKey('projects.Project')
        location =                      models.ForeignKey('projects.Location')
        employee =                      models.ForeignKey('users.User')
        task =                          models.CharField(max_length = 10) #Need 
Task Model
        notes =                         models.CharField(max_length = 1000)
        completed =                     models.BooleanField()

        def __unicode__(self):
                return u'%s: %s' % (self.project, self.employee)

class BetaEvent(models.Model):
        alpha_event =           models.ForeignKey(AlphaEvent)
        date =                          models.DateField() #Needs to be unique 
for date on user

        def __unicode__(self):
                return u'%s: %s (%s)' % (AlphaEvent.project, 
AlphaEvent.employee,
self.date)


On Nov 6, 12:10 am, Håkan Waara <[EMAIL PROTECTED]> wrote:
> 6 nov 2008 kl. 08.42 skrev joshuajenkins:
>
>
>
>
>
> > I'm sure I'm doing this wrong but can't really find an answer in the
> > docs or by searching.
>
> > I have two models (relative to this problem). One is called events,
> > one is called projects
>
> > a portion of models.py for projects looks like this:
>
> > from django.db import models
>
> > class AlphaEvent(models.Model):
> >    project =                       models.ForeignKey('projects.Project')
> >    location =                      models.ForeignKey('projects.Location')
>
> > class BetaEvent(models.Model):
> >    alpha_event =           models.ForeignKey(AlphaEvent)
>
> > I'm not sure if I'm importing the other models incorrectly or
> > referencing them incorrectly, but something is obviously going wrong.
> > When trying to add a new BetaEvent I get the following error:
>
> > project must be accessed via instance
>
> To get the Project and Location models into your namespace, you use  
> the python import statement. So what you can do is:
>
> from projects.models import Project, Location
>
> and you'll have access to those models and can reference them as usual.
>
> If you're new to python, I recommend the python tutorial. It teaches  
> you all basic concepts you will need to get up and running with django  
> development;http://docs.python.org/tutorial/index.html
>
> /Håkan
--~--~---------~--~----~------------~-------~--~----~
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