Modify ↓
Ticket #47 (closed defect: fixed)
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.
Attachments
Change History
comment:2 Changed 4 years ago by andrew
- Status changed from closed to reopened
- Resolution fixed deleted
comment:3 Changed 4 years ago by andrew
- Status changed from reopened to assigned
Gah, wrong button. It should be 'assigned', not 'fixed'.
Note: See
TracTickets for help on using
tickets.

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?).