title: django-rest ignore certain fields for certain objects
body: <p>I'm having an issue with rest-framework I'm not even sure if this is the right way to go about it or not. I have the following model</p>
  
  <pre><code>class Post(models.Model):
      user = models.ForeignKey(User)
  
      created = models.DateTimeField(auto_now_add=True)
      updated = models.DateTimeField(auto_now=True)
      date = models.DateTimeField(auto_now=True)
  
      show = models.BooleanField(default=True)
  
      title = models.CharField(max_length=100, blank=True, null=True)
      body = models.TextField(null=True, blank=True)
      role = models.IntegerField(max_length=1, choices=POST_OPTIONS, default=1)
      image = models.ImageField(upload_to="photos", blank=True, null=True)
      s3Url = models.URLField(blank=True, null=True)
      tags = TaggableManager()
  </code></pre>
  
  <p>And the following serializer for rest-framework</p>
  
  <pre><code>class PostSerializer(serializers.HyperlinkedModelSerializer):
      image_url = serializers.Field(source='get_imgage_url')
      image_file = serializers.ImageField()
      role = serializers.Field(source='get_role')
  
      class Meta:
          model = Post
  
          fields = ('url', 'user', 'created', 'updated', 'date', 'show', 'title', 'body', 'role', 'image_url', 'image')
          read_only_fields = ('user', 'created', 'updated')
  </code></pre>
  
  <p>So there are 2 kinds of posts.. a image and a text post. I dont want to show image or image_url if there is no image in the post. </p>
  
  <p>I can't figure out how to make rest-framework do that. </p>
  
  <p>thanks for the help!</p>