mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-05-27 08:24:07 +00:00
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
This commit is contained in:
parent
d6a05a0ccb
commit
a98c0d2904
2 changed files with 8 additions and 6 deletions
|
|
@ -9,6 +9,7 @@ We follow [Semantic Versions](https://semver.org/) starting at the `0.14.0` rele
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- Fixes missing `Add another` button for inlines in `BaseEntityAdmin`
|
- Fixes missing `Add another` button for inlines in `BaseEntityAdmin`
|
||||||
|
- Fixes saving of Attribute date types rendering using `BaseDynamicEntityForm` [#261](https://github.com/jazzband/django-eav2/issues/261)
|
||||||
|
|
||||||
## 1.2.3 (2022-08-15)
|
## 1.2.3 (2022-08-15)
|
||||||
|
|
||||||
|
|
|
||||||
13
eav/forms.py
13
eav/forms.py
|
|
@ -2,29 +2,29 @@
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from django import forms
|
|
||||||
from django.contrib.admin.widgets import AdminSplitDateTime
|
from django.contrib.admin.widgets import AdminSplitDateTime
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.forms import (
|
from django.forms import (
|
||||||
BooleanField,
|
BooleanField,
|
||||||
CharField,
|
CharField,
|
||||||
ChoiceField,
|
ChoiceField,
|
||||||
DateTimeField,
|
Field,
|
||||||
FloatField,
|
FloatField,
|
||||||
IntegerField,
|
IntegerField,
|
||||||
ModelForm,
|
ModelForm,
|
||||||
|
SplitDateTimeField,
|
||||||
)
|
)
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from eav.widgets import CSVWidget
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from django.forms import JSONField
|
from django.forms import JSONField
|
||||||
except:
|
except:
|
||||||
JSONField = CharField
|
JSONField = CharField
|
||||||
|
|
||||||
from eav.widgets import CSVWidget
|
|
||||||
|
|
||||||
|
class CSVFormField(Field):
|
||||||
class CSVFormField(forms.Field):
|
|
||||||
message = _('Enter comma-separated-values. eg: one;two;three.')
|
message = _('Enter comma-separated-values. eg: one;two;three.')
|
||||||
code = 'invalid'
|
code = 'invalid'
|
||||||
widget = CSVWidget
|
widget = CSVWidget
|
||||||
|
|
@ -66,6 +66,7 @@ class BaseDynamicEntityForm(ModelForm):
|
||||||
text CharField
|
text CharField
|
||||||
float IntegerField
|
float IntegerField
|
||||||
int DateTimeField
|
int DateTimeField
|
||||||
|
date SplitDateTimeField
|
||||||
bool BooleanField
|
bool BooleanField
|
||||||
enum ChoiceField
|
enum ChoiceField
|
||||||
json JSONField
|
json JSONField
|
||||||
|
|
@ -77,7 +78,7 @@ class BaseDynamicEntityForm(ModelForm):
|
||||||
'text': CharField,
|
'text': CharField,
|
||||||
'float': FloatField,
|
'float': FloatField,
|
||||||
'int': IntegerField,
|
'int': IntegerField,
|
||||||
'date': DateTimeField,
|
'date': SplitDateTimeField,
|
||||||
'bool': BooleanField,
|
'bool': BooleanField,
|
||||||
'enum': ChoiceField,
|
'enum': ChoiceField,
|
||||||
'json': JSONField,
|
'json': JSONField,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue