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

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -