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