Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

define a required field with no default

See original GitHub issue

Issue Description

The code automatically sets the first choice as the default value:

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:closed
  • Created 8 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

avinasshcommented, Nov 12, 2015

wow this is very misleading and README should clarify.

Swamiicommented, Dec 12, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found