python - Django how to make form fields optional -


How to make the form field optional in the DNS?

My model,

  class students (models.Model): first_name = model. Kharefild (max_long = 30) last_name = models.CharField (max_length = 40) email = Models.EmailField ()    

assuming that you want to create last_name optional, you can use the attribute:

  class.model: First_name = models.CharField (max_length = 30) last_name = models.CharField (max_length = 40, empty = true) Email = models.EmailField ()   

Note that CharField < On / code> and TextField , you probably do not want to set blank (as for why to discuss See), but on other field types, you will need to, or you will not be able to save examples where the optional values ​​are omitted.

Comments

Popular posts from this blog

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

php - Sorting an multidimension array using usort fails -

Simple file compression in C -