title: django rest framework - global default model serializer
body: <p>In short, I want to have a global default serializer per model. My use case here is to create dynamic serializer- i.e creating <code>ModelSerializer</code> classes on the fly.</p>
  
  <pre><code>class Customer(models.Model):
     name = models.CharField(max_length=200)
     code = models.CharField(max_length=200)
     # many more fields..
  
  class CustomerTicket(models.Model):
     customer = models.ForeignKey(Customer)
     date = models.DateTimeField(auto_now_add=True)
     # more fields..
  </code></pre>
  
  <p>Customer will be referenced by many other models, and hence it will be serialized as a nested object. I don't want the 'code' field to appear in the output - no matter what it should always be excluded.</p>
  
  <p>Now I'd like to create a function:</p>
  
  <pre><code>def serialize_default(model, fields, queryset):
      class S(serializers.ModelSerializer):
          class Meta:
              model = model 
              fields = fields
              depth = 1
      return S(queryset, many=True)
  </code></pre>
  
  <p>if I serialize <code>CustomerTicket</code> queryset using this function, I will get all the customer fields as a nested object. I know I can override it locally, but I want to define a CustomerSerializer that will be used by default (for the nested Customer here) unless other serializer is specified as a field. How to achieve this?</p>