from marshmallow import Schema, fields

from ..models.core import Post


class PostSchema(Schema):
    id = fields.Integer()
    title = fields.String()
    body = fields.String()
    is_published = fields.Boolean()

    def make_object(self, data):
        return Post(**data)

from marshmallow import Schema, fields, post_load

from ..models import Post


class PostSchema(Schema):
    __model__ = Post

    id = fields.Integer()
    title = fields.String()
    body = fields.String()
    is_published = fields.Boolean()

    class Meta:
        ordered = True

    @post_load
    def make_object(self, data):
        return self.__model__(**data)

Fix post schema for latest marshmallow release
Fix post schema for latest marshmallow release

- from marshmallow import Schema, fields
+ from marshmallow import Schema, fields, post_load
  
- from ..models.core import Post
+ from ..models import Post
  
  
  class PostSchema(Schema):
+     __model__ = Post
+ 
      id = fields.Integer()
      title = fields.String()
      body = fields.String()
      is_published = fields.Boolean()
  
+     class Meta:
+         ordered = True
+ 
+     @post_load
      def make_object(self, data):
-         return Post(**data)
+         return self.__model__(**data)
  
Fix post schema for latest marshmallow release
## Code Before:
from marshmallow import Schema, fields

from ..models.core import Post


class PostSchema(Schema):
    id = fields.Integer()
    title = fields.String()
    body = fields.String()
    is_published = fields.Boolean()

    def make_object(self, data):
        return Post(**data)

## Instruction:
Fix post schema for latest marshmallow release
## Code After:
from marshmallow import Schema, fields, post_load

from ..models import Post


class PostSchema(Schema):
    __model__ = Post

    id = fields.Integer()
    title = fields.String()
    body = fields.String()
    is_published = fields.Boolean()

    class Meta:
        ordered = True

    @post_load
    def make_object(self, data):
        return self.__model__(**data)
