Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the max size of 'max_length' in Django?

This is my model:

class Position(models.Model):     map = models.ForeignKey(Map,primary_key=True)     #members=models.CharField(max_length=200)     LatLng = models.CharField(max_length=40000)     infowindow = models.CharField(max_length=40000) 

But it can't run. What is the max size of the max_length parameter?

like image 341
zjm1126 Avatar asked Apr 08 '10 06:04

zjm1126


People also ask

What is the limit of TextField Django?

Django tip: Use models. TextField for storing long texts inside your models instead of models. CharField since CharField has a max length of 255 characters while TextField can hold more than 255 characters.

What is the difference between CharField and TextField in Django?

TextField can contain more than 255 characters, but CharField is used to store shorter length of strings. When you want to store long text, use TextField, or when you want shorter strings then CharField is useful.


2 Answers

That depends on the database backend. The Django DB Docs will tell you, that max_length=255 is guaranteed to work always.

If you need something of the amount you've specified in your question, I'd suggest to use a TextField.

like image 175
Haes Avatar answered Sep 28 '22 05:09

Haes


Use TextField instead

infowindow = models.TextField() 
like image 30
tshubham7 Avatar answered Sep 28 '22 05:09

tshubham7