Ticket #47 (closed defect: fixed)

Opened 6 years ago

Last modified 3 years ago

Automatic initial migration generation fails when models.py does not end in a blank line

Reported by: sean.b.oconnor@… Owned by: andrew
Priority: major Milestone: 0.5
Component: commands Version: 0.4
Keywords: Cc:

Description

If one executes the command "./manage.py startmigration --initial app_name" on an app where the models.py file simply ends at the end of the last field of the last model, instead of on a blank line the following error is raised:

Warning: Could not generate field definition for Model.field, manual editing of migration required.

Additionally the migration file generated contains a like for that field similar to:

('field', <<< REPLACE THIS WITH FIELD DEFINITION FOR HitEvent.date >>>),

This should be corrected so that similar models.py files can be parsed without error.

Change History

comment:1 Changed 6 years ago by andrew

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

This appears to be a bug in the inspect module - it's not returning that last line when we ask it for the model source.

We're probably going to have to write a workaround somehow, or see if inspect can be fixed (and possibly bundle the fixed version, if it can be fixed in Python?).

comment:2 Changed 6 years ago by andrew

  • Status changed from closed to reopened
  • Resolution fixed deleted

comment:3 Changed 6 years ago by andrew

  • Status changed from reopened to assigned

Gah, wrong button. It should be 'assigned', not 'fixed'.

comment:4 Changed 6 years ago by andrew

  • Version changed from subversion to 0.4
  • Milestone set to The Future

Pushing to The Future, along with #41 and #45, as this will involve a parser for models.py files.

comment:5 Changed 6 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Milestone changed from The Future to 0.5

Fixed in the ORM Freezer parser rewrite ([140] - [143]). Note that the new startmigration is called 'startmigration2' until it's stabler.

Note: See TracTickets for help on using tickets.