Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primary keys with Django 3.2+ #5

Open
uri-rodberg opened this issue Feb 14, 2021 · 1 comment
Open

Primary keys with Django 3.2+ #5

uri-rodberg opened this issue Feb 14, 2021 · 1 comment
Assignees

Comments

@uri-rodberg
Copy link
Member

Adding DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' in settings creates new migrations for django-friendship with Django 3.2+. I think it's better to define the primary keys to allow big integers in the app and add the migrations. django-friendship may be used in a database where there are more than 2**31 friendship requests or other models, and it's better to use BigAutoField than the default AutoField, and also to define those in the app and not to rely on the site's settings. When relying on settings a migration is created within django-friendship, but this package is installed as it is and should include all its migrations.

If I use django-friendship as it is without defining DEFAULT_AUTO_FIELD in settings, I get these warnings with Django 3.2 alpha:

friendship.Block: (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 AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
friendship.Follow: (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 AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
friendship.Friend: (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 AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
friendship.FriendshipRequest: (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 AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

Tested with Django 3.2 alpha.

revsys#126

@uri-rodberg uri-rodberg self-assigned this Feb 14, 2021
@uri-rodberg
Copy link
Member Author

Working on it. I'm waiting for Django 3.2 to be released to production, since AppConfig.default_auto_field is introduced only in Django 3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant