define a required field with no default
See original GitHub issueThe code automatically sets the first choice as the default value: https://github.com/5monkeys/django-enumfield/blob/master/django_enumfield/db/fields.py#L16-L17
I think this behavior is misleading because if someone defines a field with no default, he expects the field to have no default assigned so that an error is raised if the field is also required.
Right now, it’s impossible to have a required field (null=False
) with no default that would work as expected in the admin.
enum.EnumField(STATUSES, blank=True, null=False)
Setting default=None
obviously doesn’t work as the whole code assumes there is a value.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Mandatory field without default value - UX Stack Exchange
It proves the value came from the user. They cannot say - I did not select that. OK to the defaults is not...
Read more >how do you set up a required select without a default value ...
Per this answer, you can use HTML5's required attribute on a <select> if you give the default <option> an empty value attribute (among...
Read more >Defining required fields and default values - Documentation
Required fields must be populated for all instances of actions. For example, the Found by field is required and does not have a...
Read more >Defining required fields and default values | Helix ALM User ...
When a field is required, users must enter information in the field before they can save any changes. You can also define default...
Read more >mandatory fields without default - ServiceNow Community
I have set up set of fields as strings with mandatory ticked on the dictionary. Whatever option I take - puts a default...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
wow this is very misleading and README should clarify.
@clovis1122 I’m not sure I follow. What is the issue you want to solve exactly? An example of a model would help me understand.