Thursday, June 30, 2011

Re: Global generic files? Best practice(s)?

Hello Andre! Thanks so much for your help, I really appreciate the pro
advice!!! :)

On Thu, Jun 30, 2011 at 6:01 AM, Andre Terra <> wrote:
> app1/
> app2/
> appN/
>    templates/
> project/
>    templates/
>    static/
>    (etc.)

Oooh, I really like the above setup!

That's similar to how I setup my very first Django project/app (sorry,
poorly packaged... er, not packaged at all!):


That layout seemed to work well for that particular project.

At work, we use a more out-of-the-box setup:


I really like your suggested setup though! Putting the apps at the
same level as the project seem to make a lot of sense.

Using the project as a container for is a great idea also. :)

> Which basically means my project is just another app. Nothing is
> preventing you from creating files in your apps, or even
> that get loaded from an import in your project's settings.

Yes! That sounds like an optimal setup! :)

When you talk about an app's file, do you just put
something like this:

from app import settings

... at the top of the project's file?

I had never considered doing that before... I will have to experiment.
Thanks for tip!

> I find this arrangement to be the best for my development workflow
> after many other attempts. This also helps newcomers avoid the often
> made mistake of referencing their apps in relation to the project like
> from project.app1 import views
> which would prevent the code from being reused in other projects.

Hehe, I can relate. Been there, done that. :)

> About your Place model, my recommendation/guess would be to abstract
> it one more time so that you could have a global BasePlace class which
> gets subclassed in an app-specific Place model.

That's an interesting idea!

I actually have several (abstract) models similar to "Place" that I
could use in my various apps/projects... I have found myself
duplicating the code for these various apps... It would be great to
put them at a higher level and import/sub-class as they are needed.

> Or at least that's what I thought last nignt before going to sleep. As
> I write this, I realize that a BasePlace would have no place (pun not
> intended) in your project, so maybe what you need is a package for
> your multiple apps which in turn gets imported into your project.

That's a great idea/tip!

You inspired me to create my first pip-installable package:

Not much there at the moment, but I plan on adding more code at a later date.

The instructions found below were very helpful:

On my testing server, I was able to pip install django-goodies without
a hitch (I have yet to actually import and utilize the Place model in
a project/app though... It's getting late.) :(

> I'm pretty much guessing at this point, but in doing so, I have
> hopefully given you food for thought while also bumping the thread so
> that other developers will weigh in.

Definitely! Thanks so much!!!! I really appreciate it! :)

Have a great day.


Micky Hulse
Web Content Editor
The Register-Guard
3500 Chad Drive
Eugene, OR 97408
Phone: (541) 338-2621
Fax: (541) 683-7631
Web: <>

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment