Weird problem in common_settings include

22 views
Skip to first unread message

florian

unread,
Dec 13, 2012, 3:24:19 AM12/13/12
to django...@googlegroups.com
Hi,

for my project, i hav a mobile_manage.py and a manage.py. Each has its specific settings, but has also lots of sommon settings.

Thus, i've created a common_settings.py and included it in the specific settings (settings.py and mobile_settings.py). Howerver, it doesn't work.

There's no error message when i start the server (either with runserver or using fcgi/nginx), but when i try to access the homepage i gent an "ImproperlyConfigured" error, telling me that django.contrib.contenttypes is not in my INSTALLED_APPS. It is in my INSTALLED_APPS and the debugging after this error (the settings displayed in the "Request Information" part) show that it is really defined correctly.

So, do i use it the wrong way or is this a bug?

thanks for your help

Florian

Tom Evans

unread,
Dec 13, 2012, 7:02:10 AM12/13/12
to django...@googlegroups.com
On Thu, Dec 13, 2012 at 8:24 AM, florian <florian...@gmail.com> wrote:
> Hi,
>
> for my project, i hav a mobile_manage.py and a manage.py. Each has its
> specific settings, but has also lots of sommon settings.

Er, why have two versions of manage.py? One of the arguments manage.py
takes is the name of your settings module.

Put all your common settings into 'settings_default.py'.

Add your mobile settings as 'settings_mobile.py' and default as
'settings_default.py'.

In each of them, start the file with 'from settings_default import *'.
Add any overrides or other settings after that.

Run your server with "python manage.py --settings=settings_mobile" (or
"--settings=project.settings_mobile", depending on how your project is
structured.

With mod_wsgi, set the appropriate DJANGO_SETTINGS_MODULE environment variable.

>
> Thus, i've created a common_settings.py and included it in the specific
> settings (settings.py and mobile_settings.py). Howerver, it doesn't work.
>
> There's no error message when i start the server (either with runserver or
> using fcgi/nginx), but when i try to access the homepage i gent an
> "ImproperlyConfigured" error, telling me that django.contrib.contenttypes is
> not in my INSTALLED_APPS. It is in my INSTALLED_APPS and the debugging after
> this error (the settings displayed in the "Request Information" part) show
> that it is really defined correctly.

Use manage.py to open a django shell. Import settings as django would
("from django.conf import settings"). Is contenttypes in
settings.INSTALLED_APPS?


Cheers

Tom

florian

unread,
Dec 13, 2012, 7:27:36 AM12/13/12
to django...@googlegroups.com, teva...@googlemail.com
Hi,


On Thursday, December 13, 2012 1:02:10 PM UTC+1, Tom Evans wrote:
Er, why have two versions of manage.py? One of the arguments manage.py
takes is the name of your settings module.

Put all your common settings into 'settings_default.py'.

Add your mobile settings as 'settings_mobile.py' and default as
'settings_default.py'.

In each of them, start the file with 'from settings_default import *'.
Add any overrides or other settings after that.

Run your server with "python manage.py --settings=settings_mobile" (or
"--settings=project.settings_mobile", depending on how your project is
structured.

With mod_wsgi, set the appropriate DJANGO_SETTINGS_MODULE environment variable.

it's exactly what i've done, except that i've two different manage.py instead of using --settings option
I'll try with the option instead of different manage.py
 
Use manage.py to open a django shell. Import settings as django would
("from django.conf import settings"). Is contenttypes in
settings.INSTALLED_APPS?


i'll try this with my current setup and with the --settings stuff

thanks for your answer

Florian 

florian iragne

unread,
Dec 13, 2012, 7:47:34 AM12/13/12
to django...@googlegroups.com
Ok, i've get rid of my "special" mobile_manage.py and pass the
--settings option when i start the fcgi process (i use nginx+fcgi, no
mod_wsgi).

Using manage.py, with each settings file, i can verify that the
INSTALLED_APPS is correct and complete. However, i still get the error

any idea?

thanks

Florian

Bill Freeman

unread,
Dec 14, 2012, 5:17:07 AM12/14/12
to django...@googlegroups.com

How are you combining INSTALLED_APPS from the two files?  Note that simply "setting" it to what you want to add in the file that includes the other *replaces* the value you have imported from the other.  Be sure to use += instead of = .

Also, if you run "python manage.py shell" you can "from django.conf import settings" and poke around at the values that you are actually setting, which may give a clue.

Finally, you can put "import pdb; pdb.set_trace()" at/near the top of one or the other file and single step your way along to explore how execution differs from your plan.

Bill

florian

unread,
Dec 14, 2012, 8:39:52 AM12/14/12
to django...@googlegroups.com


On Friday, December 14, 2012 11:17:07 AM UTC+1, ke1g wrote:

How are you combining INSTALLED_APPS from the two files?  Note that simply "setting" it to what you want to add in the file that includes the other *replaces* the value you have imported from the other.  Be sure to use += instead of = .

INSTALLED_APPS = COMMON_INSTALLED_APPS + SPECIFIC_INSTALLED_APPS

in each specific settings file
 
Also, if you run "python manage.py shell" you can "from django.conf import settings" and poke around at the values that you are actually setting, which may give a clue.


From the shell, INSTALLED_APPS value is as expected

 
Finally, you can put "import pdb; pdb.set_trace()" at/near the top of one or the other file and single step your way along to explore how execution differs from your plan.

I'll try this

thanks
 

Bill Freeman

unread,
Dec 14, 2012, 11:09:23 AM12/14/12
to django...@googlegroups.com
On Fri, Dec 14, 2012 at 8:39 AM, florian <florian...@gmail.com> wrote:


On Friday, December 14, 2012 11:17:07 AM UTC+1, ke1g wrote:

How are you combining INSTALLED_APPS from the two files?  Note that simply "setting" it to what you want to add in the file that includes the other *replaces* the value you have imported from the other.  Be sure to use += instead of = .

INSTALLED_APPS = COMMON_INSTALLED_APPS + SPECIFIC_INSTALLED_APPS

in each specific settings file

This should work fine.  The only caveat is that in some corner cases the order of things in INSTALLED_APPS matters.

 
Also, if you run "python manage.py shell" you can "from django.conf import settings" and poke around at the values that you are actually setting, which may give a clue.


From the shell, INSTALLED_APPS value is as expected

So "django.contrib.contenttypes", the app it's complaining about, is there, and spelled correctly?  What happens when you try to import it directly from the shell?


 
Finally, you can put "import pdb; pdb.set_trace()" at/near the top of one or the other file and single step your way along to explore how execution differs from your plan.

I'll try this

thanks


Bill

Reply all
Reply to author
Forward
0 new messages