Monday, 15 August 2011

django - many to many relation does't be unique when I use intermediate model. -



django - many to many relation does't be unique when I use intermediate model. -

i utilize intermediate model "manytomanyfield using through" normally,if don't utilize intermediate field, m2m relation unique , can't have duplicated data.

after utilize intermediate model. relation between m2m can have same data. this

| | ['0'] ( | | | addtoprofile => array (0) | | | ( | | | ) | | | enddate = null | | | feedtype = "n" | | | id = 1 | | | info = "big kuy no fear" | | | likemaker => array (3) | | | ( | | | | ['0'] = "/api/v2/user/2/" | | | | ['1'] = "/api/v2/user/2/" | | | | ['2'] = "/api/v2/user/2/" | | | ) | | | like_count = "3"

i building social network. feed object has 3 like_count s . 3 of come same user "/api/v2/user/2/"

i seek add together "unique=true" attribute @ m2m field django come error because does't grant permission add together "unique" attribute m2m field @ first. can help me

try utilize unique_together in intermediate model.

class m2mmodel(models.model): field1 = models.foreignkey(model1) field2 = models.foreignkey(model2) class meta: unique_together = ('field1', 'field2')

django many-to-many tastypie relation

No comments:

Post a Comment