I have a manyTomany field between my
project model and
name = models.CharField(max_length=100, null=True, blank=True)
last_updated = models.DateField(null=True, blank=True)
contracts = models.ManyToManyField('Contract', blank=True)
address = models.CharField(max_length=150, null=True, blank=True, unique=False)
This has been working fine for months. Last night I did a bulk upload from a
csv file directly into the database.
Now when I go into the project and select the contract, it doesn’t save anymore.
I’m doing all of this in the admin, so don’t have any views or forms.
I restored the database back to the day before the bulk upload and everything is fine. So something I have done has caused this to break. But I’m not sure why or how to troubleshoot
I guess that something in the upload has messed up the relationship between the models of something.
At any point in this process, are you getting anything in the error logs on the server? That would be the first thing to check.
Side note: It makes no sense to have
blank=True on a ManyToManyField, I suggest you remove it.
I’m not getting any errors. Everything seems to be fine.
I’ve run it locally and i get the same problem, but no errors or anything outputted to terminal
I’ll remove the
You go into the admin for a
You select a
Contract for that
You save the
The relationship between
Contract is not saved.
You have no errors in the server log.
For debugging / diagnostics -
Within the database, check the Project-Contract join table for invalid entries. (Actually, also check to see if the intended entry exists.)
Check the individual rows for project and contract to verify that there’s no invalid data in any column of those two rows.
Check the admin history log to see if the update is shown there.
Double-check your Project admin class.
Run some other verification on the tables on the database looking for invalid or improper data.
But basically, in the absence of any logging information to help, assume nothing. Do not say (or think) that “I know the problem isn’t there” - verify everything.