specify the foreign keys in a ManyToManyField created table?
I have a model that auto created an auto inc id field as primary key. It related smoothly with my person model, but when I try to create a relation to committees (Komiteer) I get a new intermediate table with (an auto inc primary key, that's ok, a working relation to commitees, smooth and a non working wrong data type field that I'd expect to link to persons)
Heres the model with the ManyToManyField:
class Dagensrepresentanter(models.Model):
person = models.ForeignKey(Personer, related_name='dagensrepresentanter_person')
vara_for = models.ForeignKey(Personer, blank=True, null=True, related_name='dagensrepresentanter_vara_for')
komiteer = models.ManyToManyField(Komiteer)
it generats this intermediate table (I only included the fields for simplicity):
`id` int(11) NOT NULL AUTO_INCREMENT,
`dagensrepresentanter_id` int(11) NOT NULL,
`komiteer_id` varchar(150) NOT NULL,
The line in italics is a int(11), and probably links fine with the auto generated id in the model for Dagensrepresentanter but it need to link to the person field. In the person table the datatype for this value is varchar(33) NOT NULL
How do I specify that the foreign key in the intermediate table is the person field from the Dagensrepresentanter model?
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/j4-k2caVkpYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home