Ticket #53 (closed defect: wontfix)

Opened 6 years ago

Last modified 6 years ago

error when default callable is static method

Reported by: anonymous Owned by: andrew
Priority: minor Milestone:
Component: migrations Version:
Keywords: Cc:

Description

File "/var/djangoapps/proj/app/migrations/0001_initial.py", line 49, in forwards

('other_model', models.ForeignKey?(OtherModel?, default=OtherModel?.default)),

AttributeError?: type object 'MockModel?' has no attribute 'default'

OtherModel?.default is a @staticmethod on the OtherModel? class that returns the default based on current database state.

Change History

comment:1 Changed 6 years ago by andrew

  • Status changed from new to closed
  • Resolution set to wontfix

Now, this is difficult, as the whole reason MockModels? exist is because their model's code might change or even vanish. Thus, having a call to a callable on that original code in there isn't going to work so well in the future.

I think, in this case, the best thing to do is replace that OtherModel?.default line with something that will do the right job. In this case, it might be OK to import the 'real' OtherModel? class under a different name, and use its default:

from app.models import OtherModel as OtherModelOrig
...
('other_model', models.ForeignKey(OtherModel, default=OtherModelOrig.default)),

This will still fail if you remove models later, though. That might be fixed if we ever introduce an option that will run normal syncdb once, then --fake South's app version up to the newest revision, as opposed to just running through all revisions.

However, since this bug is pretty much unsolveable, and startmigration isn't really designed to cover EVERY use case (just _most_ of them), I'm marking as WONTFIX.

comment:2 Changed 6 years ago by anonymous

fair enough

Note: See TracTickets for help on using tickets.