Thanks everyone, I could use that link myself. On Mon, Jun 21, 2010 at 5:23 AM, vcarney <vincecar...@gmail.com> wrote:
> I've now got this working by also adding the following to my projects > settings.py file: > > import os > import sys > PROJECT_ROOT = os.path.dirname(__file__) > sys.path.insert(0, os.path.join(PROJECT_ROOT, "apps")) > > manage.py now knows about my apps folder. See Greg Allard's post for > more info if you run into this - > > http://codespatter.com/2009/04/10/how-to-add-locations-to-python-path-for-reusable-django-apps/ > . > > On Jun 20, 10:10 pm, vcarney <vincecar...@gmail.com> wrote: > > I attempted to add my apps folder to the wsgi script file, but still > > no luck (same module import error). Here is what I have in my wsgi > > script file: > > > > import os > > import sys > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings' > > sys.path.append('/apps/django') > > sys.path.append('/apps/django/example/apps') > > import django.core.handlers.wsgi > > application = django.core.handlers.wsgi.WSGIHandler() > > > > Any thoughts? > > > > On Jun 20, 11:26 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > > > > > On Jun 20, 8:01 am, vcarney <vincecar...@gmail.com> wrote: > > > > > > I created a new project with django-admin.py as such: > > > > > > django-admin.py startproject foo > > > > > > Under the folder foo it gives me the basic files: > > > > __init__.py > > > > manage.py > > > > settings.py > > > > urls.py > > > > > > I then created a new folder under foo named apps and added a blank > > > > __init__.py. Within the apps folder I created a new app with django- > > > > admin.py instead of manage.py: > > > > > > django-admin.py startapp bar > > > > > > This gives me the basic files within bar like models.py. I also > > > > created a new managers.py file within this same bar directory: > > > > > > __init__.py > > > > managers.py > > > > models.py > > > > tests.py > > > > views.py > > > > > > In my foo/bar/models.py file, I need to import a class from > > > > managers.py. I have tried "from bar.managers import PublicManger" > > > > which gives me an ImportError stating no module is named > bar.managers. > > > > However, when I import with "from foo.apps.bar.managers" it works. > > > > > > How do I decouple the project name within my apps so I may distribute > > > > the source code? > > > > > The 'apps' directory is not on your pythonpath, so you won't be able > > > to import directly from it without referencing its parent, which is. > > > However from the bar.models file 'from managers import PublicManager' > > > should work, because the current file's containing directory is always > > > automatically on the pythonpath. > > > > > I usually use a similar layout, with apps in an 'apps' subdirectory, > > > and what I usually do is slightly hack the manage.py script to put > > > apps on the path: > > > sys.path.insert(0, > > > os.path.join( > > > os.path.realpath(os.path.dirname(__file__)), 'apps' > > > ) > > > ) > > > (and a similar version in my .wsgi file for production). > > > -- > > > DR. > > -- > 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<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.com -- 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.