-
Notifications
You must be signed in to change notification settings - Fork 0
Dp less 4 #13
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: main
Are you sure you want to change the base?
Conversation
…ние в админке как с помощью formset, так и с помощью lQuery на странице со списком заказов
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.
Looks good. Worth considering though
| ) | ||
|
|
||
| # удалять заказы пользователя если пользователь был удалён - не самая лучшая идея, по этому выставлю SET_NULL | ||
| user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, 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.
| user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True) | |
| user = models.ForeignKey( | |
| settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True | |
| ) |
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.
Expect unwanted behavior if null and blank are different values: null controls if the database allows no value for user and blank controls if the application allows no value for user. Consider setting null and blank to the same value for user.
|
|
||
| class OrderItem(models.Model): | ||
| order = models.ForeignKey(Order, related_name="order_items", on_delete=models.CASCADE) | ||
| product = models.ForeignKey(Product, verbose_name='продукт', 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.
Извиняюсь, на работе завал, на выходных сделаю и пришлю