-
Notifications
You must be signed in to change notification settings - Fork 43
code doctor test #55
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: initial_commit
Are you sure you want to change the base?
code doctor test #55
Conversation
Feature/#64 split purchase by weights
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.
Worth considering. View full project report here.
|
|
||
|
|
||
| class PurchaseWeight(TimestampMixin, models.Model): | ||
| purchase = models.ForeignKey("purchases.Purchase", on_delete=models.CASCADE) |
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.
Django automatically creates a related_name if it's not set. If it were set then a more readable and explicit relationship is set up. More details.
|
|
||
| class PurchaseWeight(TimestampMixin, models.Model): | ||
| purchase = models.ForeignKey("purchases.Purchase", on_delete=models.CASCADE) | ||
| member = models.ForeignKey("auth.User", on_delete=models.CASCADE) |
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.
Again, with an explicit related_name would be better.
Makes it easier to e.g. use 3 for everyone except one person.
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.
Worth considering. View full project report here.
| user_id = obj["user__id"] | ||
| filepath = os.path.join( | ||
| output_dir, | ||
| "{0}{1}".format(user_id, ext), |
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.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. Read more.
No description provided.