jazzband / django-push-notifications

Send push notifications to mobile devices through GCM or APNS in Django.
MIT License
2.24k stars 605 forks source link

Creating a ForeignKey or OneToOneField to a model in this package generates migrations #642

Open levinotik opened 2 years ago

levinotik commented 2 years ago

This package seems to be fundamentally broken. To recreate the issue, simply create a model with something along the lines of the following:

class MyModel(models.Model):
    device = models.OneToOneField(GCMDevice, related_name='my_model', on_delete=models.CASCADE)

then run

python manage.py makemigrations

The result is that Django tries to generate migrations inside of the django-push-notifications package. The only side which should generate migrations is the model with the concrete field, namely MyModel

simonkern commented 2 years ago

That happens most likely due to the AutoField which can be customized since Django 3.2, see:

https://docs.djangoproject.com/en/4.0/releases/3.2/

https://docs.djangoproject.com/en/4.0/ref/settings/#std:setting-DEFAULT_AUTO_FIELD

Have set the default to BigAutoField in your settings?

If you specify the app you intend to create migrations for, this will no longer be an issue.

levinotik commented 2 years ago

Hmm, thanks. I'm not on Django 3.2 just yet though and the migrations were generated even when specifying only my app.