Thursday, April 11, 2013

Re: Custom Commands?

On Thu, Apr 11, 2013 at 1:22 PM, Mark Lybrand <mlybrand@gmail.com> wrote:
> Sorry about that, here is the tuple in question:
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> # 'django.contrib.admindocs',
> 'polls',
> )
>
> I have the x.py command working now. As I placed the management/commands in
> the polls app as opposed the mysite "thing". So that I am calling things
> what they need to be called, the outer folder (the one that the Django docs
> say I can rename) is that the project directory? Or is the inner directory
> of the same name, which I have been thinking of as a "base app" the project
> directory? The "base app" is not in the INSTALLED_APPS tuple, but you are
> saying that I CAN include it there and have the management/commands stuff in
> there if I think it makes organizational sense? Does making the "base app"
> an INSTALLED_APP bring with it any security or performance issues I should
> be aware of?
>
> Thanks for all the help.
>

So INSTALLED_APPS is a bit of magic. It's used by various things in
django to load resources. Eg:
When you run syncdb, Django installs models from app.models for each
app in INSTALLED_APPS
The templating system, templates and custom template tags are
searched for in each of the apps in INSTALLED_APPS
Management commands are loaded by searching
app.management.commands.<commandname> for each app in INSTALLED_APPS
The admin site discovers the models it knows about by loading
app.admin from each app in INSTALLED_APPS

I'm probably missing some..

You can make your project directory an app if you wish. My golden rule
is "an app is a module that provides any of models, templates,
template tags, admin or management commands".

I keep them separate to avoid confusion, so I will have a 'site' app
that provides the homepage/similar views, site specific models,
templates and so on, and a separate 'project' module that just
contains the settings, the top level urlconf and DB routers.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate