Serializers

Blog API serializers

class djangoapp_sample.serializers.blog.BlogSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Complete representation for detail and writing usage.

get_view_url(obj)[source]

Return the HTML detail view URL.

If request has been given to serializer this will be an absolute URL, else a relative URL.

get_article_count(obj)[source]

Return count of related articles.

class djangoapp_sample.serializers.blog.BlogResumeSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Simpler Blog representation for nested list. It won’t be suitable for writing usage.

Article API serializers

class djangoapp_sample.serializers.article.ArticleSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Complete representation for detail and writing usage.

Blog relation have two serializer fields, one for read only to return resumed details and another one for write only with complete detail and which expect a blog ID.

get_view_url(obj)[source]

Return the HTML detail view URL.

If request has been given to serializer this will be an absolute URL, else a relative URL.

class djangoapp_sample.serializers.article.ArticleResumeSerializer(instance=None, data=<class 'rest_framework.fields.empty'>, **kwargs)[source]

Simpler Article representation for nested list. It won’t be suitable for writing usage.