Why is this many-to-many relation changing whitout me asking for it, using the Django ORM? -
i have recursive m2m relationship indicator class. indicator int, or calculated value 2 indicators:
class indicator(models.model): params = models.manytomanyfield('self', verbose_name=__(u'parameters'), related_name='params_of', blank=true, null=true) type = models.charfield(max_length=64, verbose_name=__(u'type')) def get_value(self, record): # etc
according type, get_value doesn't same things. can return numerical value or calculate value numerical value of each parameters params
attribute. can see params
recursive m2m relationship.
now problem that, have follwoing indicators:
- men
- women
- total pop
- men ratio
if add men
, women
parameters of total pop
, fine, , total pop dynamically calculated. if add men
, total pop
parameters men ratio
, then total pop
automatically men ratio
parameter. breaks everything.
why that? how can avoid it?
m2m relations in django symmetric default ie in m2m, if related b b related a. stop this, use symmetrical=false
your params become:
params = models.manytomanyfield('self', verbose_name=__(u'parameters'), related_name='params_of', blank=true, null=true, symmetrical=false)
Comments
Post a Comment