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.
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
On Feb 1, 4:25 pm, "Martin J. Laubach" <mjl+goo...@emsi.priv.at>
wrote:
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
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
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
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
[...]
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
How could I handle this ?
Thanks