Commit 7a5535bc authored by Jean-Baptiste's avatar Jean-Baptiste

update: make django pagination works

parent cd9a45ee
Pipeline #4801 passed with stage
in 1 minute and 20 seconds
......@@ -228,6 +228,16 @@ Only `name` will be serialized
## Custom urls
To add customs urls who can not be add through the `Model` class, it's possible de create a file named `djangoldp_urls.py`. It will be executed like an `urls.py` file
## Pagination
To enable pagination feature just add this configuration to the server `settings.py` :
```
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 20
}
```
## License
Licence MIT
......@@ -40,10 +40,14 @@ class LDListMixin:
return [getattr(self, self.child_attr).to_internal_value(item) for item in data]
def to_representation(self, value):
try:
model = getattr(self, self.child_attr).Meta.model
except AttributeError:
model = value.model
return {'@id': self.id,
'@type': 'ldp:Container',
'ldp:contains': super().to_representation(value),
'permissions': Model.get_permissions(value.model, self.context['request'].user, ['view', 'add'])
'permissions': Model.get_permissions(model, self.context['request'].user, ['view', 'add'])
}
def get_attribute(self, instance):
......
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