Hello,
I would like to implement multicolumns primary keys in django.
I've tried to implement an AutoSlugField() which concatenate my columns values(foreignkey/dates) ...
models.py :
class ProductProduction(models.Model):
enterprise = models.ForeignKey('Enterprise')
product = models.ForeignKey('Product')
date = models.DateTimeField()
count = models.IntegerField()
slug = AutoSlugField(populate_from=
lambda instance: instance.enterprise.username + '-' + instance.product.name + '-' + str(date))
When I pass the following parameters :
- 'Megacorp','robot','09/10/2010',5 => slug = 'Megacorp-robot-09/10/2010'
... the next time in pass the triplet, a new value has been inserted :
- 'Megacorp','robot','09/10/2010',10 => slug = 'Megacorp-robot-09/10/2010'
=> same slug value => insert ????
I tried to add primary_key=True
parameter to the slug... but it creates new instance with a "-1" "-2" ... and NO update is made at all...
Did I miss something ?
Thanks,
Yoan