-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to reset django form field initial value #1050
Comments
Right.
Try using a callable: myField = forms.CharField(
widget=forms.HiddenInput(),
initial=lambda: f"2023-{settings.FIELD_BASE}",
) If this doesn't work, I think mocking |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a django form with a field defined like this:
I'm writing a test where I'd like to use
@pytest.mark.parametrize
to test different values ofFIELD_BASE
. Something like:This does not work. My hunch is that it's because
initial
is set when the module is loaded at the beginning of the test run. So I tried reloading, adding the two lines after the settings update:Still no luck.
Any thoughts on how to handle this?
The text was updated successfully, but these errors were encountered: