KeyError when trying to save model instance. It has to react on post_save signal than save instance...
Code:
from django.db.models.signals import post_save
class PlaylistEntry(models.Model):
playlist=models.ForeignKey(Playlist)
media=models.ForeignKey(Media)
order=models.PositiveIntegerField(default=9000000, editable=False)
added=models.DateTimeField(default=datetime.datetime.now(),editable=False )
def playlist_entry_changed(sender, instance, **kwargs):
entrys=PlaylistEntry.objects.filter(playlist=instance.playlist).order_by('order')
entrys[0].save()
post_save.connect(playlist_entry_changed, PlaylistEntry)
Error:
Exception Type: KeyError at /admin/playlist/playlistentry/add/
Exception Value: 38539456