Good day, Using a ManyToManyField as in the example below causes django to automatically instantiate a Model called country_region with fields country_id and region_id, which is very cool. But what if the region_country database table (for reasons beyond the scope of this thread) has field names other than country_id and region_id?
Django generates the field names in the many-to-many table based on the model names of the related tables, so the only way I have found to achieve this is to change the two Model names. But that forces me to have model names that I don't want! How can I tell django what field names to use in the automatic many-to-many Model? I have tried explicitly specifying the many-to-many Model using the through= keyword argument of the ManyToManyField, and this works, but then forms based on the Region Model do not allow saving... Any advice greatly appreciated, Randal *class Country(models.Model):* * country_id = models.AutoField(primary_key=True)* * country_name = models.CharField(max_length=200)* * class Meta:* * managed = False* * db_table = 'country'* * def __unicode__(self):* * return '%s' % (self.country_name)* *class Region(models.Model):* * region_id = models.AutoField(primary_key=True)* * region_name = models.CharField(max_length=200)* * region = models.ManyToManyField(Country, db_table='region_country')* * class Meta:* * managed = False* * db_table = 'region'* -- 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 http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/27fe68df-7d07-44c9-8231-c1dbf72ca37d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.