I think it may be a bug in modelformset_factory in Django 1.2, but I’d like anyone else to double check that (possibly in newer djnago versions as well).
Just for courious people – models are representing possible scores, and sets of those available for worker’s training reports.
models.py:
class ScoreSet(Model):
unit = ForeignKey(Unit)
description = CharField(max_length=20, verbose_name='description')
class Score(Model):
scoreset = ForeignKey(ScoreSet)
score = CharField(max_length=8, verbose_name='score')
description = CharField(max_length=30, verbose_name='description')
and now:
FormSet = modelformset_factory(Score, exclude='scoreset', extra=5, can_delete=True)
will produce formset with no scoreset and no score field. If you change “scoreset” field name to anything else (eg. “ss”) it works fine, and excludes only “ss” field.
Exclude should be a tuple, not a string: