I have created the two tables order and payment and i want to show the payment status to 1 if the payment is sucessful but iam getting this error TypeError: django.db.models.fields.related.ForeignObject.init() got multiple values for keyword argument 'to_fields'
This is my model
class payment(models.Model):
paymentid=models.AutoField(primary_key=True)
email=models.ForeignKey(Users, verbose_name=("user"), on_delete=models.CASCADE,to_field='email')
paid=models.BooleanField(default=False)
class order(models.Model):
email=models.ForeignKey(Users,on_delete=models.CASCADE,to_field='email')
product=models.ManyToManyField(Product)
quantity=models.IntegerField(null=False,blank=False)
Totalprice=models.IntegerField(blank=True,null=True)
order_time=models.DateTimeField(auto_now_add=True)
payment=models.ForeignKey(payment,on_delete=models.CASCADE,to_field='paid')
address=models.CharField(max_length=50,null=True)
status=models.CharField(max_length=50,null=True,default="pending")
#Need Help in models
3 messages · Page 1 of 1 (latest)
Please see #readme-1st for code formatting guide
you're trying to use to_field='paid' for the foreign key relationship with the payment model, but the paid field in the payment model is a boolean, not a field that can be used as a reference for a foreign key, you don't need the 'to_field'