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