我正在尝试创建一个新表。
我的序列化器:
class Animal{
private $name;
public function __construct($name) {
$this->name = $name;
}
public function Greet(){
echo "Hello, I'm some sort of animal and my name is ", $this->name ;
}
}
class Dog extends Animal{
private $type;
public function __construct($name,$type) {
$this->type = $type;
parent::__construct($name);
}
public function Greet(){
echo "Hello, I'm a ", $this->type, " and my name is ", $this->name;
}
}
$dog2 = new Dog('Jock','dog');
$dog2->Greet();
视图集:
class PostSandBox(serializers.Serializer):
def create(self, validated_data):
print(validated_data)
return Sheets.objects.create(**validated_data)
所以我的问题是class Sandbox(mixins.CreateModelMixin, viewsets.GenericViewSet):
serializer_class = PostSandBox
始终为空。
我该如何解决?