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

c# - passing input text from view to contoller with FacebookContext using Facebook app -

ios - Does Core Data autoupdate a many to many relationship on saving -

Calling a C++ function from C# by passing a string with variable size to it -