google-code-export / django-modeltranslation

Automatically exported from code.google.com/p/django-modeltranslation
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

The model "Car" is not registered for translation #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Apache + wsgi
2. settings.py Debug = False
3. If Debug = True all ok..

Traceback (most recent call last):
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/core/handlers/wsgi.py", line 272, in __call__
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     response = 
self.get_response(request)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/core/handlers/base.py", line 169, in get_response
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     response = 
self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/core/handlers/base.py", line 214, in handle_uncaught_exception
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     if 
resolver.urlconf_module is None:
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/core/urlresolvers.py", line 274, in _get_urlconf_module
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     
self._urlconf_module = import_module(self.urlconf_name)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/utils/importlib.py", line 35, in import_module
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     __import__(name)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/django/montenegro/urls.py", line 16, in <module>
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     
admin.autodiscover()
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/contrib/admin/__init__.py", line 26, in autodiscover
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     
import_module('%s.admin' % app)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/utils/importlib.py", line 35, in import_module
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     __import__(name)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/django/montenegro/page/admin.py", line 79, in <module>
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     
admin.site.register(Car, CarAdmin)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/djang
o/contrib/admin/sites.py", line 100, in register
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     
self._registry[model] = admin_class(model, self)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/model
translation/admin.py", line 70, in __init__
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     trans_opts = 
translator.get_options_for_model(self.model)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]   File 
"/home/users2/m/measurer/virtualenv/montenegro/lib/python2.7/site-packages/model
translation/translator.py", line 236, in get_options_for_model
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86]     'translation' % 
model.__name__)
[Tue May 08 22:59:03 2012] [error] [client 66.249.71.86] NotRegistered: The 
model "Car" is not registered for translation

Original issue reported on code.google.com by Lehab...@gmail.com on 9 May 2012 at 4:02

GoogleCodeExporter commented 9 years ago
I need help!!!!!!!

Original comment by Lehab...@gmail.com on 25 May 2012 at 6:22

GoogleCodeExporter commented 9 years ago
try this:
in settings.py remove the project name from the import:
MODELTRANSLATION_TRANSLATION_REGISTRY = 'project_name.translation'

Change it to:
MODELTRANSLATION_TRANSLATION_REGISTRY = 'translation'

Original comment by anto...@projecto24.com on 11 Jun 2012 at 1:04

GoogleCodeExporter commented 9 years ago
i check it, but problem not fix

Original comment by Lehab...@gmail.com on 12 Jun 2012 at 3:55

GoogleCodeExporter commented 9 years ago
Could be the rare (but known) race condition where the models aren't all loaded 
but modeltranslation tries to register them. The recent changes regarding app 
registration (per-app with autoregister in urls.py) in trunk are supposed to 
resolve this issue.

Original comment by eschler on 10 Jul 2012 at 9:21

GoogleCodeExporter commented 9 years ago
Im still getting this error, with multiple models....

/****************** ERROR ***************************/

    super(TranslationAdmin, self).__init__(*args, **kwargs)
  File "/home/udemunco/.env/env/lib/python2.7/site-packages/modeltranslation/admin.py", line 26, in __init__
    self.trans_opts = translator.get_options_for_model(self.model)
  File "/home/udemunco/.env/env/lib/python2.7/site-packages/modeltranslation/translator.py", line 463, in get_options_for_model
    'translation' % model.__name__)
modeltranslation.translator.NotRegistered: The model "Person" is not registered 
for translation

/****************** ERROR ***************************/

translation.py -

from modeltranslation.translator import translator, TranslationOptions
from .models import Category, Person, Home, Article, Footer

class CategoryTranslationOptions(TranslationOptions):
    fields = ('label', 'slug', 'topBannerTitle')

class PersonTranslationOptions(TranslationOptions):
     fields = ('role')

admin.py -

from django.contrib import admin
from .models import Category, CategoryAdmin, Footer, FooterAdmin, Home, 
HomeAdmin, Person, PersonAdmin, Article, ArticleAdmin
from django_markdown.admin import MarkdownModelAdmin
from modeltranslation.admin import TranslationAdmin, 
TranslationGenericStackedInline

class CategoryAdmin(TranslationAdmin):
    class Media:
        js = (
            'modeltranslation/js/force_jquery.js',
            'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js',
            'modeltranslation/js/tabbed_translation_fields.js',
        )
        css = {
            'screen': ('modeltranslation/css/tabbed_translation_fields.css',),
        }

class PersonAdmin(TranslationAdmin):
    class Media:
        js = (
            'modeltranslation/js/force_jquery.js',
            'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js',
            'modeltranslation/js/tabbed_translation_fields.js',
        )
        css = {
            'screen': ('modeltranslation/css/tabbed_translation_fields.css',),
        }

admin.site.register(Category, CategoryAdmin)
admin.site.register(Person, PersonAdmin);

Original comment by abfelixs...@gmail.com on 11 Aug 2014 at 5:53