From 5f6b29fd323bc835d77bc8ceadee09a0646f69a8 Mon Sep 17 00:00:00 2001
From: Calum Mackervoy <c.mackervoy@gmail.com>
Date: Thu, 26 Mar 2020 17:15:32 +0000
Subject: [PATCH] if urlid field is missing, it's ignored

---
 README.md                | 3 ++-
 djangoldp/serializers.py | 8 +-------
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 5494c583..bf25d9b0 100644
--- a/README.md
+++ b/README.md
@@ -48,10 +48,11 @@ When implementing authentication in your own application, you have two options:
 
 Please see the [Authentication guide](https://git.startinblox.com/djangoldp-packages/djangoldp/wikis/guides/authentication) for full information
 
-If you're going to use your own model then your user model must extend `DjangoLDP.Model`, or define a `urlid` field on the user model, for example:
+If you're going to use your own model then for federated login to work your user model must extend `DjangoLDP.Model`, or define a `urlid` field on the user model, for example:
 ```python
 urlid = LDPUrlField(blank=True, null=True, unique=True)
 ```
+If you don't include this field, then all users will be treated as users local to your instance
 
 The `urlid` field is used to uniquely identify the user and is part of the Linked Data Protocol standard. For local users it can be generated at runtime, but for some resources which are from distant servers this is required to be stored
 
diff --git a/djangoldp/serializers.py b/djangoldp/serializers.py
index c4e52fc7..65bdc175 100644
--- a/djangoldp/serializers.py
+++ b/djangoldp/serializers.py
@@ -6,7 +6,7 @@ from urllib import parse
 from django.conf import settings
 from django.contrib.auth import get_user_model
 from django.core.exceptions import ImproperlyConfigured
-from django.core.exceptions import ValidationError as DjangoValidationError, FieldDoesNotExist
+from django.core.exceptions import ValidationError as DjangoValidationError
 from django.core.urlresolvers import get_resolver, resolve, get_script_prefix, Resolver404
 from django.db.models import QuerySet
 from django.utils.datastructures import MultiValueDictKeyError
@@ -626,9 +626,6 @@ class LDPSerializer(HyperlinkedModelSerializer):
                 elif hasattr(field_model, 'urlid'):
                     kwargs = {'urlid': field_dict['urlid']}
                     sub_inst = field_model.objects.get(**kwargs)
-                else:
-                    raise FieldDoesNotExist(
-                        'model ' + str(field_model) + ' lacked urlid field, but urlid was submitted')
             # try slug field, assuming that this is a local resource
             elif slug_field in field_dict:
                 kwargs = {slug_field: field_dict[slug_field]}
@@ -720,9 +717,6 @@ class LDPSerializer(HyperlinkedModelSerializer):
                     elif hasattr(field_model, 'urlid'):
                         kwargs = {'urlid': item['urlid']}
                         saved_item = self.get_or_create(field_model, item, kwargs)
-                    else:
-                        raise FieldDoesNotExist(
-                            'model ' + str(field_model) + ' lacked urlid field, but urlid was submitted')
                 else:
                     rel = getattr(instance._meta.model, field_name).rel
                     try:
-- 
GitLab