So I have this pre-existing database that I'm trying to connect to using Django and I've already introspected the database and I'm just cleaning up the models before actually doing anything, and I've run into a roadblock. One of the database tables has a row:
"name" character varying NOT NULL
and when I've run python manage.py syncdb
, I get the following error:
app.artistname: "name": CharFields require a "max_length" attribute that is a positive integer.
So I went into models.py to find out what the problem is, and I see:
name = models.CharField(unique=True, max_length=-1)
So my question is, what value should I set max_length to if not even the definition in the database has a value set? Do I just set it to the maximum possible value?
For a field of varying length, you can use a TextField
instead of a CharField
so you don't have to set a size.
Both varying length fields and TextField
s are generally intended for large amounts of text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With