Skip to content
Snippets Groups Projects
Commit 22a0e910 authored by Calum Mackervoy's avatar Calum Mackervoy
Browse files

overriding Model.objects to provide local() convenience function

parent 5041c716
No related branches found
No related tags found
1 merge request!123Container urls not contain backlinks
Pipeline #5089 passed with stage
in 21 seconds
......@@ -13,8 +13,17 @@ from djangoldp.fields import LDPUrlField
from djangoldp.permissions import LDPPermissions
class LDPModelManager(models.Manager):
# an alternative to all() which exlcudes external resources
def local(self):
queryset = super(LDPModelManager, self).all()
internal_ids = [x.pk for x in queryset if not Model.is_external(x)]
return queryset.filter(pk__in=internal_ids)
class Model(models.Model):
urlid = LDPUrlField(blank=True, null=True, unique=True)
objects = LDPModelManager()
def __init__(self, *args, **kwargs):
super(Model, self).__init__(*args, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment