neversaint
neversaint

Reputation: 64054

How can I enable default value display under Django CharField

I have in Django models.py this line:

class Method1(models.Model):
    # other param
    species_param   = models.CharField(max_length=20, choices=(('mouse', 'Mouse'), ('human','Human'))

It looks like this:

enter image description here

Note that the default value is set to ----. I want to set it to Mouse. How can I do it?

I'd like also to remove the --- altogether.

Upvotes: 0

Views: 73

Answers (2)

RAN
RAN

Reputation: 1453

Suggestion :

Try with initial='mouse'

Documentation : https://docs.djangoproject.com/en/dev/ref/forms/fields/#initial

Upvotes: 0

user2114189
user2114189

Reputation: 450

I do not test it but it may solve your problem:

class Mehod1(models.Model):
    # other param
    species_param = models.CharField(max_length=20, choices=(('mouse', 'Mouse'), ('human', 'Human')), default='mouse')

Upvotes: 2

Related Questions