Relocation Apps to subfolder

61 views
Skip to first unread message

Tim Johnson

unread,
May 7, 2013, 10:01:26 PM5/7/13
to Django ML
FYI1: 'Old' pythonist, but CGI and cli utilities only. django noob.
I'm playing with django (~1.3) and using "Django 1.0 Website
development" by Hourieh as a a tutorial.

FYI2: I have developed and used my own MVC'ish framework for some
time now.

It would be my preference to locate an app under an apps directory.
I.E. where Hourieh would have one create an app, one would would
create an 'apps' directory at the next level below the project root,
then create the application below that level.

Example
cd my/shiny/new/django/project
django-admin.py startproject myproj
mkdir apps
cd apps
manage.py startapp myapp1

I can't imagine any issues with that, but if anyone were to, please
let me know your opinion.

TIA
--
Tim
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com

Russell Keith-Magee

unread,
May 7, 2013, 10:37:03 PM5/7/13
to django...@googlegroups.com
On Wed, May 8, 2013 at 10:01 AM, Tim Johnson <t...@akwebsoft.com> wrote:
FYI1: 'Old' pythonist, but CGI and cli utilities only. django noob.
I'm playing with django (~1.3) and using "Django 1.0 Website
development" by Hourieh as a a tutorial.

FYI2: I have developed and used my own MVC'ish framework for some
time now.

It would be my preference to locate an app under an apps directory.
I.E. where Hourieh would have one create an app, one would would
create an 'apps' directory at the next level below the project root,
then create the application below that level.

Example
cd my/shiny/new/django/project
django-admin.py startproject myproj
mkdir apps
cd apps
manage.py startapp myapp1

I can't imagine any issues with that, but if anyone were to, please
let me know your opinion.
 
As long as you can set up the PYTHONPATH so that the modules can be imported, there's no issues with this approach. A Django "App" is just a Python module. As long as it can be imported, you can use it. In fact, you'll find some people who advocate for keeping your "apps" directory completely separate from your project directory, to emphasise the fact that in order to maximise reusability, the app should be completely independent of your project. 

The only real restriction is a django-related namespace issue -- you can't have two apps with the same name, even if they have different fully qualified module paths (i.e., you can't have my.little.admin and django.contrib.admin in the same project because they both have an app name of "admin").  

Yours,
Russ Magee %-)

Tim Johnson

unread,
May 7, 2013, 11:13:00 PM5/7/13
to django...@googlegroups.com
* Russell Keith-Magee <rus...@keith-magee.com> [130507 18:40]:
> On Wed, May 8, 2013 at 10:01 AM, Tim Johnson <t...@akwebsoft.com> wrote:
<..> > Example
> > cd my/shiny/new/django/project
> > django-admin.py startproject myproj
> > mkdir apps
> > cd apps
> > manage.py startapp myapp1
> >
> > I can't imagine any issues with that, but if anyone were to, please
> > let me know your opinion.
> >
>
> As long as you can set up the PYTHONPATH so that the modules can be
> imported, there's no issues with this approach. A Django "App" is just a
> Python module. As long as it can be imported, you can use it. In fact,
Great. And of course, with imp, modules can be 'imported' in a
fine-grained fashion.

> you'll find some people who advocate for keeping your "apps" directory
> completely separate from your project directory, to emphasise the fact that
> in order to maximise reusability, the app should be completely independent
> of your project.
:) Great minds run the in the same gutter.

> The only real restriction is a django-related namespace issue -- you can't
> have two apps with the same name, even if they have different fully
> qualified module paths (i.e., you can't have my.little.admin and
> django.contrib.admin in the same project because they both have an app name
> of "admin").
Understood.
Thank you Russell
Reply all
Reply to author
Forward
0 new messages