Categories
Mastering Development

Can i change column type in database without updating Django model?

I have a django project which has created models for example:

from django.db import models

class Person(models.Model):
    title = models.CharField(max_length=30)
    description = models.CharField(max_length=30)

This creates table:

CREATE TABLE myapp_person (
    "id" serial NOT NULL PRIMARY KEY,
    "title" varchar(30) NOT NULL,
    "description" varchar(30) NOT NULL
);

Now i’m wondering can i change the column type to “LONGTEXT” without having to change the model? Would this cause an error? I don’t have access to django code but i have access to database and i’m importing data, and values are more than 30 characters.

Leave a Reply

Your email address will not be published. Required fields are marked *