Saturday, December 12, 2020

Re: value too long for type character varying(1)

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 

On Sat, Dec 12, 2020 at 1:56 PM Taofeek Jimoh Iyanda <iyandataofeek11@gmail.com> wrote:
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'

--
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/64780f11-2e95-45dd-a36c-5621a17f8a3cn%40googlegroups.com.
--
Gabrielstone😎

--
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/CAL-5MpVB5Q6SaLtCgz522Emi9XYyvzzjNuL%3DQGUtmNX0JkeSAQ%40mail.gmail.com.

No comments:

Post a Comment