-
Notifications
You must be signed in to change notification settings - Fork 12
changes to SingleOwnerMixin for Django-2.0 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the Travis configuration be updated to include the targetted Django version?
I will likely drop support for some of the older versions of Django, however, any LTS version must be maintained.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
… no attribute 'as_tuple'
|
||
|
||
class Money(object): | ||
class Money(decimal.Decimal): |
There was a problem hiding this comment.
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.
Django-2.0 compatibility