G'day, Very new to Django, I'm trying to connect to an existing MySQL database that I am not familiar with. I used inspectDB to load up the database models.py file, and am seeing these errors for some of the tables :
'id' can only be used as a field name if the field also sets 'primary_key=True'. inspectDB gave me this : class Access(models.Model): udid = models.CharField(max_length=40) id = models.IntegerField(db_column='ID') # Field name made lowercase. access_date = models.DateField() access_type = models.CharField(max_length=40) version = models.CharField(max_length=20, blank=True, null=True) loginid = models.TextField(blank=True, null=True) class Meta: managed = False db_table = 'Access' And the table looks like this : CREATE TABLE `Access` ( `udid` varchar(40) NOT NULL, `ID` int(11) NOT NULL, `access_date` date NOT NULL, `access_type` varchar(40) NOT NULL, `version` varchar(20) DEFAULT NULL, `loginid` text, KEY `udid_idx` (`udid`) USING HASH, KEY `udid_idx2` (`ID`,`udid`) USING HASH, KEY `udid_idx3` (`access_date`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Is this something I need to set manually in models.py? I'm not certain if ID is a suitable primary key or not - if the primary key is udid, or if it's a mashup of ID and udid, can I tell models.py about it and if so, how? Pointers to relevant documentation much appreciated! Thank you! Carl -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a5c4365a-10ec-4159-adc3-94d4ed94355a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.