Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
# the bug is described here
# I tried to use the django-extensions implementation of UUIDField(), I have the same bug
# opened this issue for django-extensions
# I'm new to django, I just suspect that there is some code in django-admin inlines which
# assumes integer primary keys
# using : django 1.2.3 , django-extensions 0.5, PGSQL db with psycopg2
# ==============
# in
# ==============
# ==================
# in myapp/
# ==================
from django.db import models
from django.db.models import CharField
from django_extensions.db.fields import UUIDField
import uuid
except ImportError:
from django_extensions.utils import uuid
class Worker(models.Model):
id = UUIDField(primary_key=True)
other_uuid_not_pk = UUIDField()
name = models.CharField(blank=True, max_length=100)
def __unicode__(self):
class Task(models.Model):
id = UUIDField(primary_key=True)
other_uuid_not_pk = UUIDField()
description = models.CharField(blank=True, max_length=100)
workers = models.ManyToManyField(Worker, through="Todo")
def __unicode__(self):
class Todo(models.Model):
id = UUIDField(primary_key=True)
other_uuid_not_pk = UUIDField()
worker = models.ForeignKey(Worker)
task = models.ForeignKey(Task)
time_allowed = models.IntegerField(default=1)
# =================
# in myapp/
# =================
from django.contrib import admin
from myapp.models import *
class WorkerAdmin(admin.ModelAdmin):
class TodoInline(admin.TabularInline):
model = Todo
fk_name = 'task'
raw_id_fields = ('worker',)
extra = 1
class TaskAdmin(admin.ModelAdmin):
inlines = (TodoInline,),WorkerAdmin),TaskAdmin)
# Once synced and admin urls setup, foillow these steps to reproduce the bug :
# 1. Log into admin, add some workers
# 2. Go to Task admin, add a task, add a related worker to it, save
# 3. Go back to this same task admin page, and just try to save again, or add a worker and save, you got :
# MultiValueDictKeyError at /admin/myapp/task/c64af3b5-f6e4-11df-869c-001cb3bc281a/
# "Key 'todo_set-0-id' not found in <QueryDict: .....>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.