Django admin detail page not loading with UUID as primary key

Viewed 16

After migrating ids in my Django app from int (default) to UUID4 the admin detail pages are not loading anymore. List views work correctly, also rendering the correct links for the objects:

enter image description here

Link renders as

http://localhost:8000/admin/images/image/27ce8dbc-eb3f-443d-bf04-f612093cdc46/change/

But clicking on the UUID to open the details (or pasting it into a new tab) leads to infinite loading.

Happens for all admins with UUID, the ones with the conventional id work.

Models looks like this:

class Image(models.Model):
    """Uploaded images."""
    id = models.UUIDField(primary_key=True, default=uuid4)
    # more fields...

Nothing else besides id › uuid4 changed...

Tested in Google Chrome with Django v4.0.7 as well as v4.1.1.

No logs, neither in the browser console nor the Django dev server, just a loading spinner in the browser tab.

Here's the Django logging config:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse',
        },
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        },
        'require_testing_false': {
            '()': RequireTestingFalse,
        },
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'filters': ['require_debug_true'],
            'class': 'logging.StreamHandler',
        },
        'file': {
            'level': 'ERROR',
            'filters': ['require_debug_false', 'require_testing_false'],
            'class': 'logging.FileHandler',
            'filename': os.path.join(BASE_DIR, 'logs/django.log'),
        },
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false', 'require_testing_false'],
            'class': 'django.utils.log.AdminEmailHandler',
        },
    },
    'loggers': {
        'django': {
            'handlers': [
                'console',
            ],
        },
        'django.request': {
            'handlers': [
                'file',
                'mail_admins',
            ],
            'level': 'ERROR',
            'propagate': False,
        },
        'django.security': {
            'handlers': [
                'file',
                'mail_admins',
            ],
            'level': 'ERROR',
            'propagate': False,
        },
        'py.warnings': {
            'handlers': ['console'],
        },
    },
}
0 Answers
Related