Reputation: 5550
I have created a django model and used TextField for one of the attributes of the model. but when i look into the MYSQL table structure it is created as long text. How can i speify django to create a medium text filed. my model structure:
class ModelExample(models.Model):
AdditionalReqFields=models.TextField(null=True,blank=True)
Upvotes: 4
Views: 5361
Reputation: 570
The django-mysql
package includes a SizedTextField
that you can set to use MEDIUMTEXT
.
For example:
from django_mysql.models.fields import SizedTextField
AdditionalReqFields = SizedTextField(size_class=3, null=True, blank=True)
Upvotes: 0
Reputation: 154594
In short, you can't.
In longer, if a CharField
(backed by VARCHAR
) is suitable, that's an option, or create your own subclass of TextField
and override the db_type(self, connection)
method.
See also: https://docs.djangoproject.com/en/dev/howto/custom-model-fields/#django.db.models.Field.db_type
Upvotes: 5