-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix/feature] Fixed fallback fields core behavior
- Fallback fields will automatically default to None - Centralized kwarg for initialzing fallback fields. - Removed dependency for using get_field_value method to access value of a field. - Simplified logic for choice fields - Added FallbackDecimalField - Fallback fields will set value to None in the database when the field value is equal to fallback value.
- Loading branch information
Showing
10 changed files
with
192 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.. note:: | ||
|
||
- The field will return the **fallback value** whenever is set to | ||
``None``. | ||
- Setting the same value as the **fallback value** will save ``None`` | ||
(NULL) in the database. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 4.2.7 on 2024-07-24 15:20 | ||
|
||
from django.db import migrations | ||
import openwisp_utils.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("test_project", "0007_radiusaccounting_start_time_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="book", | ||
name="price", | ||
field=openwisp_utils.fields.FallbackDecimalField( | ||
blank=True, | ||
decimal_places=2, | ||
default=None, | ||
fallback=20.0, | ||
max_digits=4, | ||
null=True, | ||
), | ||
), | ||
] |
Oops, something went wrong.