On Sunday, 3 May 2020 01:38:16 UTC+1, Benedict Uwazie wrote:
I added a field called transaction_id in my models.py I want that field to be used to track every transaction on my "DuesLevy" model I imported uuid to this to happen, but each time I migrate I get this error.How do i prevent this error from occurring each time I migrate (python manage.py migrate) File "C:\Users\Benedict\Miniconda3\envs\django3\lib\site- packages\django\db\models\ fields\__init__.py", line 2344, in to_python params={'value': value},django.core.exceptions.ValidationError: ["'13615773708697' is not a valid UUID."] my models.pytrans_id = uuid.uuid4()trans_str = trans_id.intpass_trans = str(trans_str)[:12 ]cast_trans = int(pass_trans)class DuesLevy(models.Model):class_of_dues = models.CharField(max_length=30, defau lt =options.CHOOSE, choices=options.CLASS_OF_DUES, blank=T rue )payment_circle = models.CharField(max_length=30, defau lt =options.CHOOSE, choices=options.PAYMENT_CIRCLE) payment_option = models.CharField(max_length=30, defau lt =options.CHOOSE, choices=options.PAYMENT_OPTION) amount = models.DecimalField(max_digits=8, dec imal_places =2)transaction_id = models.UUIDField(max_length=100, unique=True, null=True, blank=True, editable=False, default=cast_ trans) payment_channel = models.CharField(max_length=30, defau lt =options.CHOOSE, choices=options.PAYMENT_CHANNEL_TYPE) payment_date = models.DateField() date_recorded = models.DateTimeField(auto_now_add=Tru e )user = models.ForeignKey(settings.AUTH_USER_MODEL, on_ delete =models.CASCADE)description = models.TextField(blank=True, null=Tru e )def __str__(self):return self.amountdef get_absolute_url(self): return reverse('backend:detail_dues' , kwargs={'pk' : self.id})
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/4a1d77cc-d1b8-4bd4-84cd-cd78e6d2eb76%40googlegroups.com.
No comments:
Post a Comment