I am using django and mongodb as a database i have user model
class User(models.Model):
userId = models.AutoField(primary_key=True)
username = models.CharField(max_length=255)
password = models.CharField(max_length=255)
email = models.EmailField()
phoneNo = models.CharField(max_length=15)
class Order(models.Model):
WAITING = 'waiting'
PROCESSING = 'processing'
DELIVERED = 'delivered'
STATUS_CHOICES = [
(WAITING, 'Waiting'),
(PROCESSING, 'Processing'),
(DELIVERED, 'Delivered'),
]
orderId = models.AutoField(primary_key=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)
orderItems = models.IntegerField()
orderTotalAmount = models.DecimalField(max_digits=10, decimal_places=2)
status = models.CharField(max_length=20, choices=STATUS_CHOICES)
When I add a user, it is added successfully, but when I insert the record of the order, where username is the foriegn key, I am getting the following error:
djongo.exceptions.SQLDecodeError
Keyword: FAILED SQL: SELECT %(0)s AS "a" FROM "cafe_user" WHERE "cafe_user"."userId" = %(1)s LIMIT 1 Params: (1, 1) Version: 1.3.6 Sub SQL: None FAILED SQL: None Params: None Version: None
I am using djongo as a mongodb connector for django
I using mongodb first time can anyone know what the problem is? your text