ImproperlyConfigured: You need to register...

323 views
Skip to first unread message

Bojan Mihelac

unread,
Feb 1, 2010, 4:34:17 AM2/1/10
to Django FeinCMS
There are few posts in groups and on issue tracker about this error on
mod_wsgi:

ImproperlyConfigured: You need to register at least one template for
Page before the admin code is included.

I noticed that puting 'feincms' (and other feincms apps) after the
'django.contrib.auth' in INSTALLED_APPS made the problem disappear for
me.

Martin J. Laubach

unread,
Feb 1, 2010, 10:25:48 AM2/1/10
to Django FeinCMS
> I noticed that puting 'feincms' (and other feincms apps) after the
> 'django.contrib.auth' in INSTALLED_APPS made the problem disappear for
> me.

That is probably a red herring, I just checked, I always have local
apps, feincms.*, djang.contrib.* and then the rest, so re-ordering
might just hide a problem somewhere.

mjl

Bojan Mihelac

unread,
Feb 2, 2010, 2:25:01 AM2/2/10
to Django FeinCMS
Martin, so do you think that there is some issue inside feincms that
emerge when using with mod wsgi? Or do you think it is something we do
wrong when integrating?

Bojan

On Feb 1, 4:25 pm, "Martin J. Laubach" <mjl+goo...@emsi.priv.at>
wrote:

Martin J. Laubach

unread,
Feb 2, 2010, 4:31:36 AM2/2/10
to Django FeinCMS
> Martin, so do you think that there is some issue inside feincms that
> emerge when using with mod wsgi? Or do you think it is something we do
> wrong when integrating?

No, feincms works fine with mod_wsgi. I'm just saying that in my
experience, the dreaded "you need to register a template" is caused by
some other error somewhere that in turn causes the page component
registration to fail.

On the other hand, if reordering your apps solves your problem, then
that's good for you! -- however I'd be a bit wary of calling it a
solution, there is a priori no requirement I know of in feincms to
have the apps in a certain order. You are probably cruising on a side
effect of something somewhere (don't you love those specifics? :-).

Cheers,

mjl

Bojan Mihelac

unread,
Feb 2, 2010, 9:56:49 AM2/2/10
to Django FeinCMS
On Feb 2, 10:31 am, "Martin J. Laubach" <mjl+goo...@emsi.priv.at>
wrote:

After spending some time playing with example app I am pretty sure
there is some issue going on.
If I put 'feincms.module.page' before 'feincms.module.blog' when
running with apache/mod_wsgi, ImproperlyConfigured error would be
thrown.
But if I put 'django.contrib.auth' as first item in INSTALLED_APPS, it
would not throw error again.
It is ok if I put 'example' app on first place too.

So obviously when mod_wsgi is in the game, url.py is loaded and then
models.py of all apps... I would check this more

Bojan

Bojan Mihelac

unread,
Feb 2, 2010, 6:06:21 PM2/2/10
to Django FeinCMS
More about ImproperlyConfigured: "You need to register at least one
template for Page before the admin code is included." error and
hopefully logic solution:

This error does not occur when using development web server because ./
manage.py runserver calls validate() as one of first commands, which
imports and validates all models, and thus templates get registered to
Page. If validate was not called, same error would be thrown in
development mode.

We should expect that urls.py is executed prior to our custom
models.py that would register templates to Page. As admin.autodiscover
() is on top of urls.py we should register templates before this. For
now I think it is best to import custom models.py just before
admin.autodiscover().

import example.models
from django.contrib import admin
admin.autodiscover()

I am still not sure why moving 'django.contrib.auth' or
'feincms.module.blog' to top of INSTALLED_APPS made error dissapear. I
guess importing admin module for them somehow triggered importing (or
validating) other models in project and templates for Page got
registered anyway.

hope that would help someone,
Bojan

Martin J. Laubach

unread,
Feb 3, 2010, 6:26:34 PM2/3/10
to Django FeinCMS
> More about ImproperlyConfigured: "You need to register at least one
> template for Page before the admin code is included." error

You are absolutely right, there is something fishy going on. I
experienced that problem today for the first time (and after deploying
two feincms sites without problems). I found out that it also depends
on the settings of DEBUG. As long as I set it to True, everything
works fine; setting it to False and everything goes up in flames. No
reordering of INSTALLED_APPS or manually importing something seems to
help, I only get to chose between "You need to register a template"
and "Page already registered"...

mjl

Martin J. Laubach

unread,
Feb 3, 2010, 6:42:08 PM2/3/10
to Django FeinCMS
And you are also right with validate(). I modified my wsgi startup
script to read (code lifted directly from BaseCommand.validate()):

[...]
from django.core.management.validation import get_validation_errors
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
s = StringIO()
num_errors = get_validation_errors(s, None)

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


And lo and behold! it works!

Not the cleanest of solutions, but at least it's not the shuffle
apps around game.

mjl

providenz

unread,
Feb 25, 2010, 11:31:20 AM2/25/10
to Django FeinCMS
Bojan , Martin, I'm experiencing the same issue on a shared hosting
(apache, fastcgi).
When I try to use Bojan's solution, i receive an 'already registered'.

How could I handle this ?

Thanks

providenz

unread,
Mar 2, 2010, 4:38:56 PM3/2/10
to Django FeinCMS
Ok, I solved this problem by importing my custom models in urls.py
(before the admin import) and removing this app from installed apps.

akaihola

unread,
Mar 5, 2010, 6:12:52 AM3/5/10
to Django FeinCMS

Matthias Kestenholz

unread,
Apr 22, 2010, 8:17:28 AM4/22/10
to django-...@googlegroups.com
Thanks for the summary. This is hopefully fixed by commit
bd82947c8cb0e[1], which is included in FeinCMS v1.1.0:

http://github.com/matthiask/feincms/commits/


Matthias

--
You received this message because you are subscribed to the Google Groups "Django FeinCMS" group.
To post to this group, send email to django-...@googlegroups.com.
To unsubscribe from this group, send email to django-feincm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-feincms?hl=en.

Reply all
Reply to author
Forward
0 new messages