Hi Ratan,

On Saturday 18 June 2016 14:35:08 Ratan Kulshreshtha wrote:
> hello, everyone, I think that when we make new Django app inside by running
> django-admin startapp <app-name> or by python manage.py startapp <app-name>
> name of app shoul be added automatically in settings.py file in project
> directory.
> 

The problem with this suggestion is that many projects manage their apps in 
different ways; as an example, some projects separate their included apps into 
groups, and then have something like

        INSTALLED_APPS = GROUP1_APPS + GROUP2_APPS + GROUP3_APPS

for some other projects, there are different settings files for different 
deployments, with some apps being included only in some settings, etcetera.

So, getting a general feature to just add your app to the settings file to work 
across these use-cases is hard, and doing something simplistic will, in many 
cases, create more work for developers than it will save. Thus, I think that 
adding this as a general feature to Django is probably not a good idea.

> If you think my suggestion is good then how can I implement it, any
> guidance will be helpful

On the other hand, you can do something simple in your own project, along 
these lines:

Create a text file, called (for example) "automatic_apps.txt". This file will 
include application names, one app in each line.
In your settings file, do something like:

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
] + [line.strip() for line in open("automatic_apps.txt")]

and finally, write your own startapp command -- maybe call it autoapp -- which 
invokes Django's startapp, and also adds the new app's name to 
automatic_apps.txt.

Generally speaking, the order of apps is important (they can override parts of 
each other, and the order controls who overrides who) so separating some of 
the apps to a  separate file may be counter productive.

HTH,
        Shai.

Reply via email to