3

So I got this error, and looked at this stackoverflow question: django-registration (1048, "Column 'last_login' cannot be null")

So I went into the database and deleted the row with 0005_alter_user_last_login_null.py.

After I ran: python manage.py migrate it still didn't detect any new migrations.

How am I supposed to fix my database and make the user last_login optional? I thought there might be some way to reapply a previous migration but I couldn't get that to work. Anyone have any ideas on how to fix the database?

Thanks in advance!

EDIT:

Output of python ./manage.py showmigrations auth

[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[ ] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages

Community
  • 1
  • 1
Ofek Gila
  • 693
  • 1
  • 10
  • 21
  • Your question is unclear, Are you trying to detect migrations or fix an error? Please describe the issue you're trying to solve – Sayse May 11 '16 at 06:18
  • @Sayse, thanks for your comment. I tried to clarify a bit, but I honestly don't know what it is I should do to fix the database. I'm really awful with this stuff. – Ofek Gila May 11 '16 at 06:35
  • Could post your "new migrations"? And then, I think you need to make a new migration to make the `last_login` optional rather than deleting old migration. – Edwin Lunando May 11 '16 at 06:39
  • 2
    Please show the output of `./manage.py showmigrations auth` – Alasdair May 11 '16 at 07:55
  • @EdwinLunando, I read somewhere else that migration 0005 makes it optional – Ofek Gila May 11 '16 at 20:39

1 Answers1

3

Thank you all so much! With @Alasdair's suggestion I noticed that I simply needed to run that migration again, and was able to do so by running the command:

python manage.py migrate auth 0005_alter_user_last_login_null

It works now, thanks!

Ofek Gila
  • 693
  • 1
  • 10
  • 21