Got it to happen inside the admin interface. It looks like, at least in 
this case, it's some kind of cache. I don't see the cache stuff on the 
user's listing page. I'll see if I can put a condensed version of the error 

ValidationError at /admin/<app>/log/1418765/change/
["'f45fecf0-2cad-4c66-a67f-41665732086c' is not a valid UUID."]

Error during template rendering

error at line 0
'%(value)s' is not a valid UUID.
1 {% load i18n static %}<!DOCTYPE html>
2 {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi 
3 <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI 
%}dir="rtl"{% endif %}>
4 <head>
5 <title>{% block title %}{% endblock %}</title>
6 <link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% 
static "admin/css/base.css" %}{% endblock %}" />
7 {% block extrastyle %}{% endblock %}
8 {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% 
block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% 
endif %}
9 {% block extrahead %}{% endblock %}
10 {% block responsive %}

.../django/db/models/fields/ in __get__
            rel_obj = self.field.get_cached_value(instance) ...
.../django/db/models/fields/ in get_cached_value
            return instance._state.fields_cache[cache_name] ...

During handling of the above exception ('package'), another exception 
.../django/db/models/fields/ in to_python
                return uuid.UUID(value) ...
/usr/local/lib/python3.6/ in __init__
            hex = hex.replace('urn:', '').replace('uuid:', '') ...

During handling of the above exception ('UUID' object has no attribute 
'replace'), another exception occurred:
.../django/core/handlers/ in inner....

On Monday, February 12, 2018 at 1:00:53 PM UTC-8, M Mackey wrote:
> I've run into a strange issue with using a UUID as primary key, and I'm 
> hoping we can either verify this is a bug, or figure out what I've done 
> wrong.
> I've got a core model object with a UUID for it's primary key. (Generated 
> external to this system, thus using that for when additional information 
> comes in.) And there are other model objects referencing it. Normally 
> everything runs fine. But after a while, web pages that have been running 
> fine start telling me that the UUID isn't valid (even though it is). (Sorry 
> I don't have a copy of the error at this moment, I'll post here when it 
> happens again.) I know it's not a simple coding error, because I can simply 
> restart Apache and everything is fine again. And these aren't POST 
> responses or anything complex like that. It occurs on a simple listing page.
> When I dig into the exceptions, I see something that seems contradictory. 
> It looks like the UUID constructor has been called with an instance of a 
> UUID (it says type UUID doesn't have method 'replace'). But it doesn't seem 
> like that should be possible because the code that calls that constructor 
> first checks the type. (See django/db/models/fields/ - 
> UUIDField.to_python)
> So it's a double head scratcher. Once this problem crops up, I have to 
> restart the web server (but then it's okay for a while). And the errors it 
> gives me don't make much sense.
> I don't know what kind of caching problem it could be - I haven't enabled 
> any of the available caching systems. Also doesn't seem to crop up (at 
> least not as often) in the built in dev test server.
> Anyone seen this, or have any ideas?
> Thanks,
> M

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

Reply via email to