Skip to content

Commit a98c0d2

Browse files
authored
Use SplitDateTimeField for date Attribute types (#321)
* fix: use field class SplitDateTimeField for type 'date' Fixes #261 * refactor: remove import conflict of django.forms * style: isort imports * docs: add fix #261 to changelog
1 parent d6a05a0 commit a98c0d2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ We follow [Semantic Versions](https://semver.org/) starting at the `0.14.0` rele
99
### Bug Fixes
1010

1111
- Fixes missing `Add another` button for inlines in `BaseEntityAdmin`
12+
- Fixes saving of Attribute date types rendering using `BaseDynamicEntityForm` [#261](https://github.com/jazzband/django-eav2/issues/261)
1213

1314
## 1.2.3 (2022-08-15)
1415

eav/forms.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22

33
from copy import deepcopy
44

5-
from django import forms
65
from django.contrib.admin.widgets import AdminSplitDateTime
76
from django.core.exceptions import ValidationError
87
from django.forms import (
98
BooleanField,
109
CharField,
1110
ChoiceField,
12-
DateTimeField,
11+
Field,
1312
FloatField,
1413
IntegerField,
1514
ModelForm,
15+
SplitDateTimeField,
1616
)
1717
from django.utils.translation import gettext_lazy as _
1818

19+
from eav.widgets import CSVWidget
20+
1921
try:
2022
from django.forms import JSONField
2123
except:
2224
JSONField = CharField
2325

24-
from eav.widgets import CSVWidget
25-
2626

27-
class CSVFormField(forms.Field):
27+
class CSVFormField(Field):
2828
message = _('Enter comma-separated-values. eg: one;two;three.')
2929
code = 'invalid'
3030
widget = CSVWidget
@@ -66,6 +66,7 @@ class BaseDynamicEntityForm(ModelForm):
6666
text CharField
6767
float IntegerField
6868
int DateTimeField
69+
date SplitDateTimeField
6970
bool BooleanField
7071
enum ChoiceField
7172
json JSONField
@@ -77,7 +78,7 @@ class BaseDynamicEntityForm(ModelForm):
7778
'text': CharField,
7879
'float': FloatField,
7980
'int': IntegerField,
80-
'date': DateTimeField,
81+
'date': SplitDateTimeField,
8182
'bool': BooleanField,
8283
'enum': ChoiceField,
8384
'json': JSONField,

0 commit comments

Comments
 (0)