I have define the following model: class Ingestqueue(models.Model): ingestQueueId = models.IntegerField(primary_key=True) datasetID = models.IntegerField() filename = models.CharField(maxlength=100) timeOfRemoteMOD = models.DateTimeField() ingestModuleID = models.IntegerField() dataSourceID = models.IntegerField() timeOfEntry = models.DateTimeField() status = models.CharField(maxlength=40) timeOfLastStatusUpdate = models.DateTimeField() PID = models.IntegerField()
class Admin: list_display = ('filename', 'timeOfEntry', 'status') search_fields = ('filename', 'status') class Meta: db_table = 'ingestQueue' unique_together = (("datasetID", "filename", "timeOfRemoteMOD"),) If I activate this model in Admin interface I get the next error: (1054, "Unknown column 'ingestQueue.ingestQueueId' in 'field list'") On Jan 15, 2:48 pm, "Remco Gerlich" <[EMAIL PROTECTED]> wrote: > As far as I know, it's currently not possible in Django. > > The solution would be to add a (auto-increment) ingestQueueId field as a > primary key, and in the meantime 1) declare your current primary key fields > to be unique, 2) create an index for those fields in MySQL. > > To make multiple fields unique together, use (as an inner class inside your > model class): > > class Meta: > unique_together = [("datasetID","filename","timeOfRemoteMOD")] > > Remco Gerlich > > On Jan 15, 2008 12:52 PM, Nader <[EMAIL PROTECTED]> wrote: > > > > > Hallo, > > > I have a "MySQL" table which has more than one field ad a primary key: > > > CREATE TABLE `ingestQueue` ( > > `datasetID` int(11) NOT NULL, > > `filename` varchar(80) NOT NULL default '', > > `timeOfRemoteMOD` datetime NOT NULL default '0000-00-00 00:00:00', > > `ingestModuleID` int(11) NOT NULL, > > `dataSourceID` int(11) NOT NULL, > > `timeOfEntry` datetime NOT NULL default '0000-00-00 00:00:00', > > `status` varchar(80) default NULL, > > `timeOfLastStatusUpdate` datetime NOT NULL default '0000-00-00 > > 00:00:00', > > `PID` int(11) NOT NULL, > > PRIMARY KEY (`datasetID`,`filename`,`timeOfRemoteMOD`) > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1; > > > How can define a model in Djano with a primary key which has to have > > more than one fields? > > > The "python manage.py inspectdb" give the following Django model: > > > class Ingestqueue(models.Model): > > datasetID = models.IntegerField(primary_key=True) > > filename = models.CharField(primary_key=True, maxlength=240) > > timeOfRemoteMOD = models.DateTimeField(primary_key=True) > > ingestModuleID = models.IntegerField() > > dataSourceID = models.IntegerField() > > timeOfEntry = models.DateTimeField() > > status = models.CharField(blank=True, maxlength=240) > > timeOfLastStatusUpdate = models.DateTimeField() > > PID = models.IntegerField() > > class Meta: > > db_table = 'ingestQueue' > > > Regards, > > Nader --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---