Sunday, June 20, 2010

Re: decoupling project name from import?

Am a Django noob, and I do not know what your Django proficiency is, but I'd think you have compromised the strict directory structure that Django created.  I would:

- Check that your new "apps" folder is on your PATH,
- Consider having the apps folder outside of your foo project,
- See http://docs.djangoproject.com/en/1.2/intro/tutorial03/ for a word on decoupling apps.

On Sun, Jun 20, 2010 at 9:01 AM, vcarney <vincecarney@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?

--
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 django-users+unsubscribe@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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment