Hey Russ and Waylan,
Thanks for the responses.
Russ, I actually did that:
import sys
sys.path.append("path/to/project")
from project.app import models
complained about environment settings. But when I dug into fixing that, I
over complicated the matter. Waylan's response saw through my over
complication and we get to:
import os, sys
sys.path.append("path/to/project")
os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings"
from project.app import models
and that works great.
Again, thank you both for your response.
Johnnie
On 1/10/07, Waylan Limberg <[EMAIL PROTECTED]> wrote:
>
>
> On 1/10/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
> >
> > On 1/10/07, johnnie pittman <[EMAIL PROTECTED]> wrote:
> >
> > > I'm looking to find out if there's a method to access django models in
> other
> > > applications outside of the django project structure. What I'm
> looking to
> > > do is import a model from one of the apps in my project:
> > >
> > > from project.app import models
> >
> > Have you tried doing exactly that? A Django app is just a python
> > module, so as long as project.app is on your PYTHONPATH when you run
> > manage.py, a simple import should work.
> >
> Of course, if your not running your app through manage.py, you'll need
> to define the DJANGO_SETTINGS_MODULE environment variable. After all,
> for you model to connect with a db, it'll need the connection
> settings.
>
> A minimal settings file with db connection info should do the trick.
> Depending on how you plan to run your app, you can either permenantly
> set the DJANGO_SETTINGS_MODULE environment variable via the OS or in
> you python code.
>
> In your python code this should do the trick ( where myproject is on
> your pythonpath):
>
> import os
> os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
>
>
> --
> ----
> Waylan Limberg
> [EMAIL PROTECTED]
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---