Ticket #917 (closed defect: invalid)

Opened 4 years ago

Last modified 4 years ago

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:


When changing

    user = models.ForeignKey(User)


    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?


Change History

comment:1 Changed 4 years ago by andrew

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

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.

Note: See TracTickets for help on using tickets.