doableware/djongo

Keyword: FAILED SQL: SELECT %(0)s AS "a" FROM "accounts_account" WHERE "accounts_account"."id" = %(1)s LIMIT 1 Params: (1, 1)

theriyasharma24 opened this issue · 2 comments

One line description of the issue

I am new to django and facing this mongoDB and djongo error. I am getting this error on inserting a record in UserProfile.

Python script

class Account(AbstractBaseUser):
    first_name      = models.CharField(max_length=50)
    last_name       = models.CharField(max_length=50)
    username        = models.CharField(max_length=50, unique=True)
    email           = models.EmailField(max_length=100, unique=True)
    phone_number    = models.CharField(max_length=50)

    # required
    date_joined     = models.DateTimeField(auto_now_add=True)
    last_login      = models.DateTimeField(auto_now_add=True)
    is_admin        = models.BooleanField(default=False)
    is_staff        = models.BooleanField(default=False)
    is_active        = models.BooleanField(default=False)
    is_superadmin    = models.BooleanField(default=False)

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['username', 'first_name', 'last_name']

    objects = MyAccountManager()

    def full_name(self):
        return f'{self.first_name} {self.last_name}'

    def __str__(self):
        return self.email

    def has_perm(self, perm, obj=None):
        return self.is_admin

    def has_module_perms(self, add_label):
        return True


class UserProfile(models.Model):
    user = models.ForeignKey(to=Account, on_delete=models.CASCADE)
    address_line_1 = models.CharField(blank=True, max_length=100)
    address_line_2 = models.CharField(blank=True, max_length=100)
    profile_picture = models.ImageField(blank=True, upload_to='userprofile')
    city = models.CharField(blank=True, max_length=20)
    state = models.CharField(blank=True, max_length=20)
    country = models.CharField(blank=True, max_length=20)
    dob = models.DateField(max_length=8,blank=True,null=True)
    BOOL_CHOICES1 = ((True, 'Married'), (False, 'Unmarried'))
    Marital_Status = models.BooleanField(choices=BOOL_CHOICES1)
    BOOL_CHOICES2 = (('Male', 'Male'), ('Female', 'Female'),('others','others'))
    Gender = models.CharField(max_length=20,blank=False,null=False,choices=BOOL_CHOICES2)    

Traceback

Traceback (most recent call last): File "C:\Users\theri\Desktop\Python_Amygo\amygo_python\venv\lib\site-packages\djongo\sql2mongo\query.py", line 808, in __iter__ yield from iter(self._query) File "C:\Users\theri\Desktop\Python_Amygo\amygo_python\venv\lib\site-packages\djongo\sql2mongo\query.py", line 167, in __iter__ yield self._align_results(doc) File "C:\Users\theri\Desktop\Python_Amygo\amygo_python\venv\lib\site-packages\sqlparse\tokens.py", line 19, in __contains__ return item is not None and (self is item or item[:len(self)] == self)

RecursionError: maximum recursion depth exceeded in comparison

The above exception was the direct cause of the following exception:

File "C:\Users\theri\Desktop\Python_Amygo\amygo_python\venv\lib\site-packages\djongo\sql2mongo\query.py", line 830, in iter
raise exe from e
djongo.exceptions.SQLDecodeError:

    Keyword: FAILED SQL: SELECT %(0)s AS "a" FROM "accounts_account" WHERE "accounts_account"."id" = %(1)s LIMIT 1

Params: (1, 1)
Version: 1.3.6
Sub SQL: None
FAILED SQL: None
Params: None
Version: None

I downgraded my django version to 3.2 and it worked for me.
pip install django==3.2

I downgraded Django to 4.0 is also work for me.
pip install django==4.0