Skip to content

Commit

Permalink
play nice with postgre
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Jan 4, 2024
1 parent 1486110 commit 2696830
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/utils/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from datetime import datetime

from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.fields import PositiveIntegerRelDbTypeMixin, SmallIntegerField
from django.db import models, connection
from django.db.models.fields import PositiveIntegerRelDbTypeMixin, SmallIntegerField, CharField
from django.forms import DateInput, DateField
from django.utils import timezone
from django.utils.dateparse import parse_date
Expand Down Expand Up @@ -160,7 +161,6 @@ def _get_val_from_obj(self, obj):
import json

from django import forms
from django.conf import settings
from django.db.models import JSONField as DjangoJSONField
from django.contrib.postgres.fields import (
ArrayField as DjangoArrayField,
Expand All @@ -178,15 +178,14 @@ def formfield(self, **kwargs):
"form_class": forms.MultipleChoiceField,
"choices": self.base_field.choices,
}
kwargs.pop("base_field", None)
defaults.update(kwargs)
# Skip our parent's formfield implementation completely as we don't
# care for it.
# pylint:disable=bad-super-call

# Update the 'base_field' attribute with the instance of the base field
return super(ArrayField, self).formfield(**defaults)


if "sqlite" in settings.DATABASES["default"]["ENGINE"]:

if connection.features.is_sqlite:
class JSONField(Field):
def db_type(self, connection):
return "text"
Expand Down

0 comments on commit 2696830

Please sign in to comment.