Cannot save ManyToMany fields from Django Admin interface
My sqllite3 database and Django setup are working correctly except for this single situation involving the Admin interface:
class Box(models.Model): name = models.CharField(max_length=200, primary_key=True) balls = models.ManyToManyField( 'Ball' ) class Ball(models.Model): name = models.CharField(max_length=200, primary_key=True)
I have a ManyToMany field in my Box model to contain multiple Ball models. I can create some Balls and I can even create a Box and link it to some Balls. But I cannot edit/save the Box's set of balls after it's been created without getting this server error:
DatabaseError : unable to open database file
I am using the development server (python manage.py runserver). Apart from this admin glitch, database IO works fine across my site.
Things I have tried which have not helped: 1. Deleting the database and running syncdb again to start fresh. 2. Set my db path in settings.py to a full path. 3. Running the shell I start the dev server from 'As Administrator' 4. Setting the parent, folder and db file permissions as RW
I don't know what else to try. I'm open to crazy suggestions, but hoping somebody might know what could cause this...
I got it working!
I suspected that this was an issue with sqllite3 database. Perhaps it's lack of transactional updates... I can't say for sure. So I swapped the database out for MySQL and the issue is now gone. I can create 'boxes' and add 'balls' to them now.