Here are my three models:
class Faculty(models.Model):
[standard attributes]
class WorkDay(models.Model):
[standard attributes]
class OfficeHour(models.Model):
faculty = models.ForeignKey(Faculty)
day_of_week = models.ManyToManyField(WorkDay)
and in admin.py:
class OfficeHourInline(admin.TabularInline):
model = OfficeHour
class FacultyAdmin(admin.ModelAdmin):
inlines = [OfficeHourInline]
So, editing a Faculty has inlines to OfficeHours, each of which is
coupled to a WorkDay, as well.
OfficeHours, created by any means, delete just fine from their own
section in admin, or from the shell (calling delete() on them). This
includes those created through the inline on a Faculty. They are also
completely modifiable. They *cannot*, however, be deleted through
Faculty's inline, raising a ValueError:
"'OfficeHour' instance needs to have a primary key value before a many-
to-many relationship can be used."
This seems silly, because I know that the OfficeHour instances *do*
have primary key values - I can see them in sqlite, not to mention
that I can delete them from their own admin section!
Anything I can find on that error seems to indicate that I have a
model that hasn't been saved yet, but I know that to not be the case.
Do I perhaps need to overload the delete() method on Faculty, or
OfficeHours? Any advice on a direction to look is appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---