SELECT (1) AS "a" FROM "finances"."gates_approvals" WHERE
("finances"."gates_approvals"."gate_approval_id" = 45 AND NOT
("finances"."gates_approvals"."gate_approval_id" = 45 ))
which is totally useless. Did anyone meet such a strange behaviour?
Sure:
class GatesApprovals(models.Model):
id = models.AutoField(primary_key=True, null=False,
db_column='gate_approval_id')
gate = models.ForeignKey(Gates, null=False, db_column='gate_approval_gate')
period = models.DateField(null=False, db_column='gate_approval_period')
value = models.DecimalField(null=True, default=None, max_digits=5,
decimal_places=2, db_column='gate_approval_value')
def __unicode__(self):
return str(self.gate) + ' / ' + str(self.period)
class Meta:
db_table = 'finances"."gates_approvals'
managed = False
and Gates:
class Gates(models.Model):
gate = models.IntegerField(primary_key=True,db_column='gate_id')
in_value = models.DecimalField(default=0,max_digits=4,decimal_places=2,db_column='gate_in_value')
out_value =
models.DecimalField(default=0,max_digits=4,decimal_places=2,db_column='gate_out_value')
out_limit = models.SmallIntegerField(default=0,db_column='gate_out_limit')
shared = models.BooleanField(null=False, default=False,
db_column='gate_shared')
class Meta:
db_table = u'data"."gates'
managed = False
def __unicode__(self):
return str(self.gate)
there is nothing like unique together or something - all those are
handled on database level.
I use modelformset_factory with custom form. First it was pure
ModelForm with meta part (maybe doubling instance managing i thought,
but that was not the case), then ModelForm without meta info - with
the same result. Pure form cannot be used with modelformset_factory.