starkshang
starkshang

Reputation: 8528

Why default value for column doesn't work with django

I'm using django to create database tables,model code like this:

class User(models.Model):
    uid = models.CharField(max_length=32,primary_key=True)
    nick = models.CharField(max_length=20)
    sex = models.CharField(max_length=1,default='M')
    sign = models.CharField(max_length=40,default="")

but default value doesn't work.when I show table description,shows that: enter image description here

why this code doesn't work and how can solve this problem?

Upvotes: 3

Views: 994

Answers (1)

Astar
Astar

Reputation: 268

Django doesn't add default values into the schema, instead it adds the default value if need-be when a User object is created.

Upvotes: 4

Related Questions