Sorry, which model is causing the problem? Which is the model that started giving you errors when you added the Meta?

Antonis Christofides
+30-6979924665 (mobile)



On 02/04/2022 15.00, Sunday Ajayi wrote:
Hi Antonis below is my model definition:


from django.db import models
from authentication.models import User,Business
import cloudinary
from cloudinary.models import CloudinaryField
from django.core.paginator import 
Paginator,EmptyPage,PageNotAnInteger,InvalidPage
from rest_framework.pagination import PageNumberPagination
from django.contrib.postgres.fields import ArrayField
# Create your models here.
DATA_PER_PAGE =10
class Category(models.Model):
TYPE = (
('custom','custom'),
('non-custom','non-custom')
)
STATE = (
('untrained','Untrained'),
('in-progress','Training in Progress'),
('more-training','More Training Needed'),
('trained','Trained')
)
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255, blank=True,null=True)
slug = models.CharField(max_length=20,null=True,blank=True)
category_type = models.CharField(max_length=20,choices=TYPE,default='non-custom',null=True,blank=True)
description = models.TextField(blank=True,null=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True) image = models.ImageField(upload_to='category',null=True,blank=True,default='/media/category/unnamed-5.png')
extracted_data = models.JSONField(blank=True,null=True)
state = models.CharField(max_length=20,choices=STATE,default='untrained',null=True,blank=True)
training_status = models.BooleanField(default=False,null=True,blank=True)
f1_score = models.FloatField(null=True,blank=True)
accuracy = models.FloatField(null=True,blank=True)
progessive_training_file = models.TextField(null=True, blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING,null=True,blank=True,related_name='user_cat')
def __str__(self) -> str:
return self.name
class Batch(models.Model):
id = models.AutoField(primary_key=True)
description = models.TextField(blank=True,null=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True) category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True,blank=True)
counts = models.BigIntegerField(null=True, blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True,blank=True,related_name='user_batch')
def __str__(self) -> str:
return str(self.id)
class Custom_model_extract(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True,blank=True)
image_extract = models.FileField(upload_to='custom_data',blank=True,null=True)
transcribed_data = models.JSONField(null=True,blank=True)
label_data = models.JSONField(null=True,blank=True)
extracted_json = models.JSONField(blank=True,null=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True,related_name='bus_extracted') created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True,blank=True,related_name='user_extracted')
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self) -> str:
return self.name
class Training_model_data(models.Model):
id = models.AutoField(primary_key=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True,blank=True)
# image_extract = 
models.FileField(upload_to='training_data',blank=True,null=True)
image_extract = models.TextField(blank=True,null=True)
transcribed_data = models.JSONField(null=True,blank=True)
label_data = models.JSONField(null=True,blank=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True,related_name='training_bus_extracted') created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True,blank=True,related_name='trainng_user_extracted')
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self) -> str:
return self.name
class PostManager(models.Manager):
def get_paginated_posts(self, user=None):
if user:
posts = super(PostManager, self).filter()
else:
posts = super(PostManager, self).filter()
return Paginator(posts, DATA_PER_PAGE)
class Epassport(models.Model):
id = models.AutoField(primary_key=True)
fullname = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True,blank=True) image_extract = models.FileField(upload_to='e_passport_images',blank=True,null=True)
extracted_json = models.JSONField(blank=True,null=True)
is_extracted = models.BooleanField(null=True,blank=True)
passport_number = models.CharField(max_length=20, null=True,blank=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True)
date_of_birth = models.CharField(max_length=20, null=True,blank=True)
sex = models.CharField(max_length=255, null=True,blank=True)
nationality = models.CharField(max_length=255, null=True,blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING,null=True,blank=True,related_name='user_epassport')
def get_page(self):
return self._default_manager.filter(id=self.id).filter(
business__id=self.business).count() / DATA_PER_PAGE + 1
def __str__(self) -> str:
return self.fullname
class Lassera(models.Model):
id = models.AutoField(primary_key=True)
fullname = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True,blank=True)
image_extract = 
models.FileField(upload_to='lassera_images',blank=True,null=True)
extracted_json = models.JSONField(blank=True,null=True)
is_extracted = models.BooleanField(null=True,blank=True)
id_number = models.CharField(max_length=20, null=True,blank=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True)
date_of_birth = models.CharField(max_length=20, null=True,blank=True)
sex = models.CharField(max_length=255, null=True,blank=True)
lga = models.CharField(max_length=255, null=True,blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING,null=True,blank=True,related_name='user_lassera')
def get_page(self):
return self._default_manager.filter(id=self.id).filter(
business__id=self.business).count() / DATA_PER_PAGE + 1
def __str__(self) -> str:
return self.fullname
class Nin(models.Model):
id = models.AutoField(primary_key=True)
fullname = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True,blank=True)
image_extract = models.FileField(upload_to='nin_images',blank=True,null=True)
extracted_json = models.JSONField(blank=True,null=True)
is_extracted = models.BooleanField(null=True,blank=True)
# image_extract = cloudinary.models.CloudinaryField('image', folder='/e-passport-ocr',transformation={'width': '600', 'height': '400'}, null=True, blank=True)
id_number = models.CharField(max_length=20, null=True,blank=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True)
date_of_birth = models.CharField(max_length=20, null=True,blank=True)
sex = models.CharField(max_length=255, null=True,blank=True)
address = models.CharField(max_length=255, null=True,blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING,null=True,blank=True,related_name='user_nin')
def get_page(self):
return self._default_manager.filter(id=self.id).filter(
business__id=self.business).count() / DATA_PER_PAGE + 1
def __str__(self) -> str:
return self.fullname
class Invoice(models.Model):
id = models.AutoField(primary_key=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True,blank=True) image_extract = models.FileField(upload_to='non_custom_invoices',blank=True,null=True)
extracted_json = models.JSONField(blank=True,null=True)
is_extracted = models.BooleanField(null=True,blank=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True,blank=True)
date = models.CharField(max_length=20, null=True,blank=True)
expense = models.JSONField(null=True,blank=True)
sub_total = models.CharField(max_length=20, null=True,blank=True)
sales_tax = models.CharField(max_length=255, null=True,blank=True)
total = models.CharField(max_length=255, null=True,blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING,null=True,blank=True,related_name='user_invoice')
def get_page(self):
return self._default_manager.filter(id=self.id).filter(
business__id=self.business).count() / DATA_PER_PAGE + 1
def __str__(self) -> int:
return self.id
*
*
*This started when I added the a class Meta with unique_together field*
*
*
# class Meta:
# unique_together = ('business', 'name')
*
*
*But after I removed it, and did makemigration, then migrated, then I started getting this error*
*
*
*
*
*AJAYI Sunday *
(+234) 806 771 5394
/sunnexaj...@gmail.com/



On Sat, Apr 2, 2022 at 6:49 AM Antonis Christofides <anto...@antonischristofides.com> wrote:

    Hi,

    could you show the definition of your model?

    Antonis Christofides
    +30-6979924665 (mobile)



    On 02/04/2022 00.43, Sunday Ajayi wrote:
    Hi Team,


    Please I am having the error below from django - postgresql:

    django.db.utils.OperationalError: index row requires 45344 bytes, maximum
    size is 8191


    Please how can I fix it?

    Regards,
    *AJAYI Sunday *
    (+234) 806 771 5394
    /sunnexaj...@gmail.co <mailto:sunnexaj...@gmail.com>m/
-- 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+unsubscr...@googlegroups.com.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/django-users/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com
    
<https://groups.google.com/d/msgid/django-users/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
-- 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+unsubscr...@googlegroups.com.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/django-users/d65d443e-6eeb-1daf-590b-1cc29445ba59%40antonischristofides.com
    
<https://groups.google.com/d/msgid/django-users/d65d443e-6eeb-1daf-590b-1cc29445ba59%40antonischristofides.com?utm_medium=email&utm_source=footer>.

--
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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKYSAw0DabjecG3-dQdfURhPU-N_Fs4u2V6OManQY03sq%3D37rQ%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAKYSAw0DabjecG3-dQdfURhPU-N_Fs4u2V6OManQY03sq%3D37rQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7b1efdec-47f6-8526-ffc9-36fc7df8befa%40antonischristofides.com.

Reply via email to