when i am trying to add uuid primary key , I am getting this error UNIQUE constraint failed: matrixapp_bookplot.user_id
what is wrong here
what is wrong here
ref_id = models.CharField(max_length=25)
code = str(uuid.uuid4()).replace("-", "")[:4]
user_id=models.CharField(primary_key=True,max_length=50, default=code, editable=False)
plot_number = models.CharField(max_length=25)
Payable_amout = models.IntegerField(null=True, blank=True)
Mnthly_Installment = models.IntegerField(null=True, blank=True)
number_of_Installment = models.IntegerField()
name = models.CharField(max_length=100)
father_name = models.CharField(max_length=100)
mobile_no = models.IntegerField()
payment_mode = models.CharField(max_length=10)
remarks = models.CharField(max_length=100)
receipt = models.ImageField(upload_to = 'receipt/', null= True, blank=True)
joinig_date=models.DateField(auto_now_add=True,null=True,blank=True)
def bookplot(request):
if request.method =="POST":
ref_id = request.POST.get('ref_id')
plot_number = request.POST.get('plot_number')
amount = request.POST.get('amount')
Mnthly_Installment = request.POST.get('Mnthly_installment')
no_Installment = request.POST.get('no_Installment')
name = request.POST.get('name')
father_name = request.POST.get('father_name')
mobile_number = request.POST.get('mobile_number')
payment_mode = request.POST.get('payment_mode')
remarks = request.POST.get('remarks')
receipt = request.FILES.get('receipt')
print(ref_id)
book_plot = BookPlot(ref_id= ref_id,plot_number = plot_number, Payable_amout = amount,Mnthly_Installment = Mnthly_Installment, number_of_Installment = no_Installment, name = name,father_name = father_name , mobile_no = mobile_number, payment_mode = payment_mode ,remarks=remarks,receipt=receipt )
book_plot.save()
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2d3ecd5f-6659-4efe-b836-852328bafae6n%40googlegroups.com.
No comments:
Post a Comment