speedy-net / django-friendship

Django app to manage following and bi-directional friendships
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Primary keys with Django 3.2+ #5

Open uri-rodberg opened 3 years ago

uri-rodberg commented 3 years ago

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.

https://github.com/revsys/django-friendship/issues/126

uri-rodberg commented 3 years ago

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.