value too long for type character varying(1)

332 views
Skip to first unread message

Taofeek Jimoh Iyanda

unread,
Dec 12, 2020, 6:55:58 AM12/12/20
to Django users
Hello Guys,

Please I need an urgent help on this subject, I was trying to migrate my model in django to a postgres DB but I am getting 'value too long for type character varying(1)' error. I have tried making the max_length = 1000 but I am still getting the same error. 

The last thing I can remember I did was that I create another CharField with a list of choice. I tried removing it but still getting the same error.

Below is the code i am trying to migrate:

from django.db import models
from django.utils import timezone
import datetime
# Create your models here.
SEX = [
        ('M', 'MALE'),
        ('F', 'FEMALE')
]

TITLE_CHOICES = [
        ('MR','Mr.'),
        ('MRS','Mrs.'),
        ('MS','Ms.')
]

STATUS = [
    ('A', 'Admitted'),
    ('D', 'Discharged')
]


class PatientDetail(models.Model):
    
    """
    Model of the details of entry patient 
    """
    FirstName = models.CharField(blank = False, max_length = 1000)
    LastName = models.CharField(blank = False, max_length = 1000)
    MiddleName = models.CharField(max_length = 1000)
    Title = models.CharField(choices = TITLE_CHOICES, blank=False, max_length = 1000)
    Address = models.CharField(blank = False, max_length = 1000)
    Email = models.EmailField(max_length = 1000)
    sex = models.CharField(blank = False, choices = SEX, max_length = 1000)
    Age = models.DateField(blank = False)
    PhoneNumber = models.CharField(blank = False, max_length = 1000)
    NextOfKin = models.CharField(blank = False, max_length = 1000)
    NextofKin_Address = models.CharField(blank = False, max_length = 1000)
    NextofKIn_PhoneNumber = models.DecimalField(blank = False, max_digits=13, decimal_places=0)
    DateOfReg = models.DateTimeField(auto_now=True)
    NurseInDuty = models.CharField(blank=False, max_length = 1000)
    Status = models.CharField(choices = STATUS, blank = False, max_length = 1000)
    
    
    class Meta:
        db_table = 'Patient Detail'

712189512

unread,
Dec 12, 2020, 7:22:38 AM12/12/20
to django...@googlegroups.com
It’s probably because you have already made migrations and also made some changes in your model ,if that’s the case delete the old migrations and make migrations again and should work 

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/64780f11-2e95-45dd-a36c-5621a17f8a3cn%40googlegroups.com.
--
Gabrielstone😎

Anselme Gildas Tchassem Boutchouang

unread,
Dec 12, 2020, 11:11:30 AM12/12/20
to django...@googlegroups.com
django indicates the error line. Show us this line

Le sam. 12 déc. 2020 à 15:27, Anselme Gildas Tchassem Boutchouang <tbag...@gmail.com> a écrit :
did you redo py manage.py makemigrations after your modification?



--
Anselme Gildas TCHASSEM BOUTCHOUANG
DevOps, Fullstack, Freelance
(+237) 696 319 191 / (+237) 698 544 992 / Email : aanseg...@yahoo.fr / LinkedIN : Profil LinkedIN / Facebook : Profil Facebook  / Whatsapp: (+237) 696 319 191


--
Anselme Gildas TCHASSEM BOUTCHOUANG
DevOps, Fullstack, Freelance
(+237) 696 319 191 / (+237) 698 544 992 / Email : aanseg...@yahoo.fr / LinkedIN : Profil LinkedIN / Facebook : Profil Facebook  / Whatsapp: (+237) 696 319 191

Anselme Gildas Tchassem Boutchouang

unread,
Dec 12, 2020, 11:11:30 AM12/12/20
to django...@googlegroups.com
did you redo py manage.py makemigrations after your modification?

Le sam. 12 déc. 2020 à 13:21, 712189512 <gabriels...@gmail.com> a écrit :

Taofeek Jimoh Iyanda

unread,
Dec 12, 2020, 11:31:42 AM12/12/20
to Django users
yes, I do
Reply all
Reply to author
Forward
0 new messages