Django-two-factor-auth no such table two_factor_phonedevice

Hi, first post!
Im trying to implement a 2FA solution, using the django-two-factor-auth (DTFA) package.
Everything in the installation runs smoothly, and im able to successfully login with the two_factor login template at /account/login/. However, when i go to /setup to actually setup the 2FA, i get the error: django.db.utils.OperationalError: no such table: two_factor_phonedevice.
Im running DTFA version 1.15.4, and have a custom user model, if that could be of interest.

Im quite new to Django, but when looking through the initial migrations required by DTFA, one is named:, but such a migration seems to be by design and not a bug.

Can anyone push me in the right direction?

After installing a package like this, you would generally need to run migrage to apply the changes defined by the migration file to the database.

Hi Ken, thank you for the swift reply.
I did run alle the initial migrations, which is also where i noticed the name of the final migration which was “0008_delete_phonedevice”.

Did you run a makemigrations before running the migrate?

Yes. Im going through the github and it may have something to do with moving the phonedevice to plugins: Migration from 1.13.1 to 1.15.1 is broken · Issue #611 · jazzband/django-two-factor-auth · GitHub.

1 Like

If you are using Heroku,

You can run

Heroku run Python migrate

It’s not expressed in their docs and I ran into the same table not found error. That is how I fixed it.

Thanks for replying the_homeless_coder.
I dont run on Heroku.
I got an earlier version to work however:
I downgraded first to 1.15.1 and got same error,
i then downgraded to 1.14, and then it all went smoothly.
Annoyingly i then tried to upgrade to 1.15.4, which caused the error to return.
So im gonna be running 1.14 for the time being.
Bw. MJay