Commit b02da106 authored by Rob's avatar Rob

Support default serialiser fields for all cases, remove redundant field filtering.

parent 722244a9
......@@ -37,6 +37,7 @@ class Todo(models.Model):
#### 3.1 Configure field visibility (optional)
Note that at this stage you can limit access to certain fields of models using
......@@ -53,6 +54,8 @@ from django.contrib.auth.models import User
User._meta.serializer_fields = ('username','first_name','last_name')
Note that this will be overridden if you explicitly set the fields= parameter as an argument to LDPViewSet.urls(), and filtered if you set the excludes= parameter.
### 4- Add a url in your
......@@ -81,10 +81,12 @@ class LDPSerializer(HyperlinkedModelSerializer):
serializer_url_field = JsonLdIdentityField
def get_default_field_names(self, declared_fields, model_info):
fields = super().get_default_field_names(declared_fields, model_info)
excludes = list(getattr(self.Meta, 'exclude', []))
extra = list(getattr(self.Meta, 'extra_fields', []))
return [f for f in fields if f not in excludes] + extra
fields = list(self.Meta.model._meta.serializer_fields)
fields = super().get_default_field_names(declared_fields, model_info)
return fields
def to_representation(self, obj):
data = super().to_representation(obj)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment