views:

40

answers:

3

http://code.google.com/p/django-multilingual-model/

I am trying to understand how the multilanguage feature works and i found the example in the above link

What i have done is i have created a project as test and included that in settings.py

And in the test directory i have the multilingual.py and the code for this is the above said link and then i have created the models.py as in the above link.

But when i run python manage.py shell and

    >>> from test.models import Language
    Traceback (most recent call last):
     File "<console>", line 1, in ?
     File "/opt/Project_Apr22/site/test/models.py", line 2, in ?
     from multiling import MultilingualModel
     ImportError: cannot import name MultilingualModel

How to resolve this

A: 

Are you sure that you're importing from the multiling that you think you are?

import multiling
print multiling.__file__
Ignacio Vazquez-Abrams
print multiling.__file__/opt/Project_Apr22/site/test/multiling.pyand i can do a import test.multiling
Hulk
A: 

Don't use a module name 'test', as it conflicts with python's test module.

Arthur Debert
i have changed the name from test to testlangsupport
Hulk
And that is no good? Sorry for the hasted answer then, but I've been bitten by "import test" before :)
Arthur Debert
A: 

First of all: which version of django?

For me (django 1.2) Your code dies because multiling.py is at the root of the project. Not sure is it django bug, multiling bug or bug of both.

After adding add app_label in MultilingualModel.Meta:

class MultilingualModel(models.Model):

    # ...

    class Meta:
        app_label = 'foo'
        abstract = True

everything works. I am thinking it is Django's bug. You (or maybe I) should report it...

petraszd