djongo icon indicating copy to clipboard operation
djongo copied to clipboard

ModuleNotFoundError: No module named 'django.db.models.fields.mixins'

Open hellonts opened this issue 8 years ago • 4 comments

One line description of the issue

python3.6 with django 1.11.12 mongodb 3.6.4 python manage.py makemigrations

Python script

<copy and paste code here>

Traceback

File "E:\virtualenv\cmdb\lib\site-packages\djongo\models\__init__.py", line 3, in from .fields import ( File "E:\virtualenv\cmdb\lib\site-packages\djongo\models\fields.py", line 28, in from django.db.models.fields.mixins import FieldCacheMixin ModuleNotFoundError: No module named 'django.db.models.fields.mixins'

hellonts avatar May 02 '18 06:05 hellonts

@hellonts After recent updates Djongo only supports Django 2.0 onwards.

arindammanidas avatar May 03 '18 03:05 arindammanidas

Did you install djongo from pip?

nesdis avatar May 03 '18 04:05 nesdis

yes, with django 2.0 work is normal @arindammanidas @nesdis

hellonts avatar May 03 '18 08:05 hellonts

I am still getting from django.db.models.loading import cache as model_cache ModuleNotFoundError: No module named 'django.db.models.loading' in Django 3.2.10

This is my Model:

class User(AbstractBaseUser, PermissionsMixin):
    from django.db.models.loading import cache as model_cache

    if not model_cache.loaded:
        model_cache._populate()

    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    email_address = models.EmailField(max_length=255, unique=True)
    name = models.CharField(max_length=255)
    organization_id = models.ForeignKey('organization.Organization', blank=True, null=True,
                                        on_delete=models.CASCADE, related_name='organization_id')
    practitioner_id = models.ForeignKey('practitioner.Practitioner', blank=True, null=True,
                                        on_delete=models.CASCADE, related_name='practitioner_id')
    supplier_id = models.ForeignKey('supplier.Supplier', blank=True, null=True,
                                    on_delete=models.CASCADE, related_name='supplier_id')

I also tried this:

class User(AbstractBaseUser, PermissionsMixin):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    email_address = models.EmailField(max_length=255, unique=True)
    name = models.CharField(max_length=255)
    organization_id = models.ForeignKey('organization.Organization', blank=True, null=True,
                                        on_delete=models.CASCADE, related_name='organization_id')
    practitioner_id = models.ForeignKey('practitioner.Practitioner', blank=True, null=True,
                                        on_delete=models.CASCADE, related_name='practitioner_id')
    supplier_id = models.ForeignKey('supplier.Supplier', blank=True, null=True,
                                    on_delete=models.CASCADE, related_name='supplier_id')

it give me error:

TypeError: isinstance() arg 2 must be a type or tuple of types

What wrong I am doing here? Any help is appriciated.

bhattraideb avatar Jan 27 '22 12:01 bhattraideb