I have the models like this:
class Category(models.Model):
name = models.CharField(max_length=255)
slug = models.SlugField(unique=True, max_length=255, blank=True,default=None)
desc = models.TextField(blank=True, null=True )
...
class Post(models.Model):
title = models.CharField(max_length=255)
pub_date = models.DateTimeField(editable=False,blank=True)
author = models.ForeignKey(User, null=True, blank=True)
categories = models.ManyToManyField(Category, blank=True, through='CatToPost')
...
class CatToPost(models.Model):
post = models.ForeignKey(Post)
category = models.ForeignKey(Category)
...
Here is the serializer:
class CategorySerializer(serializers.ModelSerializer):
class Meta:
model = Category
fields = ('name','slug')
class PostSerializer(serializers.ModelSerializer):
categories = CategorySerializer(many=True, required=True)
class Meta:
model = Post
.......
The views.py
class SingleListing(generics.RetrieveUpdateDestroyAPIView):
queryset = Post.objects.all()
serializer_class =Post
Serializer
But this doesn't show the category field in the web-browsable view. I only see the Category label, but the input fields of this fields is not there. What is the problem?