On Tue, 2006-08-15 at 10:29 +0000, cyberco wrote: [...] > > Have you made any > > other alterations to the model since you created the database table? Can > > you show us the table definition that the database has created? > > I changed the names of the fields in my example above for clarities > sake, but here is the actual table: > > +----+--------+----------------+ > | id | userID | t | > +----+--------+----------------+ > | 2 | 1 | 1 | > +----+--------+----------------+
I think we can safely say "yes", you did make alterations, since this is the first time column 't' has been mentioned. > > Do you get the same error when you try this from the command line > > (manage.py shell). If so, import db.connection and have a look at the > > last entry in connection.queries. It would be interesting to see that > > the SQL we are generating is what is expected. > > The (edited) SQL is: > > ================ > CREATE TABLE `translator_translation` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `userID` integer UNSIGNED NOT NULL, > `t` integer NOT NULL UNIQUE REFERENCES `translator_translator` > (`id`) > ); > CREATE UNIQUE INDEX translator_translation_translator_id ON > `translator_translation` (`translator_id`); > ================ So your model has a 't' field that you did not show in your earlier example. That is partly where your problem lies (it can't be NULL and it must be unique). You would not have been able to save your example in the previous post to that database table because the 't' attribute would have been empty. So unfortunately, the model you gave in the last post does not match your database table at all (there is apparently a ForeignKey or something like that in there). Either your model and your db table are completely out of sync, or your rewriting has missed a few important steps. If you need to rewrite your model for confidentiality's sake, could you please try and reduce it to an example that works properly and fails in the way you mention? I realise that you may not be able to show everything, but it's going to help us help you if you give accurate information about what is going on. Your initial explanation seems to have left a couple of things out that are relevant. Maybe just realising that you need to populate attribute 't' is all you need, otherwise, step back and try to come up with an example that fails in the way you describe. Best wishes, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

