class Category(Model):
name = models.CharField(max_length=45)
class Animal(Model):
name = models.CharField(max_length=45)
categories = models.ManyToManyField(Category)
@receiver(pre_save, sender=Animal)
def animal_create_update(sender, **kwargs):
# get the selected categories and do something
print(categories)
我试图找到一种在pre_save信号期间访问类别的方法。可能吗?
答案 0 :(得分:0)
你可以尝试
/*
usage: @include transition(prop1, prop2, ..., 0.5s cubic-bezier(0.16, 0.85, 0.45, 1));
*/
@mixin transition($args...) {
$type: nth($args, length($args));
$props: remove-nth($args, length($args));
$result: ();
@for $i from 1 through length($props) {
$prop: nth($props, $i);
$result: append($result, $prop);
$result: append($result, $type);
@if $i != length($props) {
$result: append($result, unquote($string: ","));
}
}
@include simple_transition($result);
}
让我知道