Modify

Ticket #917 (closed defect: invalid)

Opened 3 years ago

Last modified 3 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:

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

comment:1 Changed 3 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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.