Closed atila7840 closed 2 years ago
I'm a bit afraid we can't do much here, but still, can you identify the migration which causes this error?
D:\MyDjangoProjects\partnik>python manage.py migrate
Operations to perform:
Apply all migrations: PollApp1, admin, auth, contenttypes, otp_email, otp_static, otp_totp, sessions, two_factor
Running migrations:
Applying two_factor.0008_alter_phonedevice_id...Traceback (most recent call last):
File "D:\MyDjangoProjects\partnik\manage.py", line 22, in
The migration two_factor.0008_alter_phonedevice_id
doesn't belong to this package. My guess it that the migration was automatically created in your project due to a different DEFAULT_AUTO_FIELD setting. I'll let you investigate this idea.
I checked the table id field, it's primary key and identity.
also I commented DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' but I got:
D:\MyDjangoProjects\partnik>python manage.py migrateSystem check identified some issues:
WARNINGS:two_factor.PhoneDevice: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the TwoFactorConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.Operations to perform: Apply all migrations: PollApp1, admin, auth, contenttypes, otp_email, otp_static, otp_totp, sessions, two_factorRunning migrations: Applying two_factor.0008_alter_phonedevice_id...Traceback (most recent call last): File "D:\MyDjangoProjects\partnik\manage.py", line 22, in
On Tuesday, August 23, 2022 at 12:36:41 AM GMT+4:30, Claude Paroz ***@***.***> wrote:
The migration two_factor.0008_alter_phonedevice_id doesn't belong to this package. My guess it that the migration was automatically created in your project due to a different DEFAULT_AUTO_FIELD setting. I'll let you investigate this idea.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
I guess the solution in your case might be to create a custom app config, something like this:
from two_factor.plugins.phonenumber.apps import TwoFactorPhoneNumberConfig
class CustomPhoneAppConfig(TwoFactorPhoneNumberConfig):
default_auto_field = 'django.db.models.AutoField'
Then in your INSTALLED_APPS setting, point to that config, so instead of:
two_factor.plugins.phonenumber
use:
path.to.CustomPhoneAppConfig
Please comment directly on the GitHub interface, as your mail client is sending completely broken content.
I am using MS SQL as DB and two factor, when I run migrate I get error : Running migrations: File "C:\Python310\lib\site-packages\mssql\schema.py", line 287, in _alter_field raise NotImplementedError("the backend doesn't support altering from/to %s." % t.name) NotImplementedError: the backend doesn't support altering from/to AutoField.
Also when run python -Wa manage.py test
I get error: Found 0 test(s). C:\Python310\lib\site-packages\two_factor\views\utils.py:11: RemovedInDjango50Warning: The django.utils.baseconv module is deprecated. from django.utils import baseconv System check identified no issues (0 silenced).
python manage.py runserver Watching for file changes with StatReloader Performing system checks...
System check identified no issues (0 silenced).
You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): two_factor. Run 'python manage.py migrate' to apply them.
Your Environment
pip list Package Version
asgiref 3.5.0 atpublic 3.0.1 attrs 22.1.0 colorama 0.4.5 dj-database-url 0.5.0 Django 4.0.5 django-formtools 2.3 django-otp 1.1.3 django-phonenumber-field 6.3.0 django-recaptcha 3.0.0 django-two-factor-auth 1.14.0 jedi 0.18.1 mssql-django 1.1.3 parso 0.8.3 phonenumbers 8.12.53 pip 22.2.2 pycryptodome 3.15.0 pyodbc 4.0.34 pytz 2022.1 pytz-deprecation-shim 0.1.0.post0 qrcode 7.3.1 setuptools 58.1.0 six 1.16.0 sqlparse 0.4.2 tzdata 2022.1 tzlocal 4.2