On Wednesday, 12 November 2014 21:42:43 UTC+1, Collin Anderson wrote:
>
> Hello,
>
> That does seem odd. Are you using a custom form or custom template at all?
>

I bumped into this issue too. I made a minimal project that triggers the 
issue :

# model.py
from django.db import models


class Author(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name


class Book(models.Model):
    title = models.CharField(max_length=100)
    authors = models.ManyToManyField(Author)

    def __unicode__(self):
        return self.title




# admin.py
from django.contrib import admin
from .models import Author, Book


class AuthorshipInline(admin.TabularInline):
    model = Book.authors.through


@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    inlines = [AuthorshipInline]
    save_as = True


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    inlines = [AuthorshipInline]
    save_as = True




How to reproduce the problem using the admin :
 - create two authors
 - create a book with those two authors
 - edit the book
 - click the check box in the "Delete?" column for one of the authors
 - click "Save as new"

End of stack trace :

File 
"/home/synext/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/models/deletion.py"
 
in collect
  168.                             reverse_dependency=reverse_dependency)
File 
"/home/synext/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/models/deletion.py"
 
in add
  85.             if obj not in instances:
File 
"/home/synext/lib/python2.7/site-packages/Django-1.7.1-py2.7.egg/django/db/models/base.py"
 
in __hash__
  485.             raise TypeError("Model instances without primary key 
value are unhashable")

Exception Type: TypeError at /admin/myapp/book/1/
Exception Value: Model instances without primary key value are unhashable

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a715326d-636e-463b-a09a-b4a5ac6af201%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to