auvipy / django-sqlalchemy

Django ORM built on top of SQLalchemy core 2.0 for seamless integration of SQLAlchemy with Django 4.2+ PostgreSQL 14+ only for now. [pre POC now]

Home Page:https://pypi.org/project/django-sqlalchemy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Relative imports causes reprocessing of models which causes a problem

GoogleCodeExporter opened this issue · comments

importing differently, relatively causes it to reprocess the model and tries to 
create a new 
mapper.  We need to work around this.

>>> from categories.models import *
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/mtrier/Development/django-
sqlalchemy/tests/apps/../apps/categories/models.py", line 5, in <module>
    class Category(models.Model):
  File "/Users/mtrier/Development/django-sqlalchemy/django_sqlalchemy/models/base.py", line 
139, in __init__
    cls.__mapper__ = mapper_cls(cls, table, properties=our_stuff, **mapper_args)
  File "/Library/Python/2.5/site-packages/sqlalchemy/orm/__init__.py", line 566, in mapper
    return Mapper(class_, local_table, *args, **params)
  File "/Library/Python/2.5/site-packages/sqlalchemy/orm/mapper.py", line 175, in __init__
    self.__compile_class()
  File "/Library/Python/2.5/site-packages/sqlalchemy/orm/mapper.py", line 784, in 
__compile_class
    raise exceptions.ArgumentError("Class '%s' already has a primary mapper defined with entity 
name '%s'.  Use non_primary=True to create a non primary Mapper.  
clear_mappers() will remove 
*all* current mappers from all classes." % (self.class_, self.entity_name))
ArgumentError: Class '<class 'apps.categories.models.Category'>' already has a 
primary mapper 
defined with entity name 'None'.  Use non_primary=True to create a non primary 
Mapper.  
clear_mappers() will remove *all* current mappers from all classes.
>>> from apps.categories.models import *


Original issue reported on code.google.com by mtr...@gmail.com on 9 Apr 2008 at 11:32

Fixed in http://gitorious.org/projects/django-
sqlalchemy/repos/mainline/commits/5562d385f99a410e467b0cf90a826ce3c014b7b4. 
Thanks brosner

Original comment by mtr...@gmail.com on 10 Apr 2008 at 4:04

  • Changed state: Fixed