Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion django_extras/contrib/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class Document(SingleOwnerMixin, models.Model):

"""
owner = models.ForeignKey(USER_MODEL_NAME, verbose_name=_('owner'),
related_name='%(app_label)s_%(class)s_owner')
related_name='%(app_label)s_%(class)s_owner',
on_delete=models.CASCADE, null=True, blank=False)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for null=True?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the only way 'makemigrations' would work for me; but perhaps there is a better way?


objects = SingleOwnerMixinManager()

Expand Down
2 changes: 1 addition & 1 deletion django_extras/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def decimal_value(value):
return value


class Money(object):
class Money(decimal.Decimal):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the right solution to this problem. This class composes a money value from a Decimal amount and a currency it does not use inheritance.

"""
Represents a monetary quantity.
"""
Expand Down
2 changes: 1 addition & 1 deletion django_extras/db/models/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_db_prep_save(self, value, connection):
value = self.to_python(value)
if value is not None:
value = value._amount
return connection.ops.value_to_db_decimal(value, self.max_digits, self.decimal_places)
return connection.ops.adapt_decimalfield_value(value, self.max_digits, self.decimal_places)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change backwards compatible with Django < 2?

This might require a conditional to handle previous Django releases

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I don't know, as everything I'm doing now is Django 2+. But it seems that 'value_to_db_decimal' disappeared in Django 1.9



class PercentField(models.FloatField):
Expand Down
2 changes: 1 addition & 1 deletion django_extras/db/models/fields/jsonfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __repr__(self):
return dumps(self)


class JsonField(six.with_metaclass(models.SubfieldBase, models.TextField)):
class JsonField(models.TextField):
"""Field that serializes/de-serializes a python list/dictionary to the
database seamlessly."""

Expand Down