Modify ↓
Ticket #917 (closed defect: invalid)
Changing a required foreignkey to default=None and null=True results in requiring user input
| Reported by: | dpn | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | migrations | Version: | 0.7.3 |
| Keywords: | Cc: |
Description
When changing
user = models.ForeignKey(User)
to
user = models.ForeignKey(User, null=True, default=None)
I get the following error:
? The field 'SuggestedBrand.user' does not have a default specified, yet is NOT NULL. ? Since you are making this field nullable, you MUST specify a default ? value to use for existing rows. Would you like to: ? 1. Quit now, and add a default to the field in models.py ? 2. Specify a one-off value to use for existing columns now ? 3. Disable the backwards migration by raising an exception.
Am I doing it wrong?
Cheers!
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

No, that's correct - it's prompting you for what it should do in the reverse migration (making a NULLable field into a non-NULLable field requires a default).
You probably just want to answer 3 unless you want backwards migrations.