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

Consider adding default_auto_field to AppConfig #202

Closed
amartinezuy opened this issue Oct 5, 2022 · 0 comments · Fixed by #211
Closed

Consider adding default_auto_field to AppConfig #202

amartinezuy opened this issue Oct 5, 2022 · 0 comments · Fixed by #211

Comments

@amartinezuy
Copy link

Hello,

Starting with Django 3.2, newly created projects will include the following line in settings.py:

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

When installing django-invitations in such a context and running python manage.py migrate we get the following message:

Your models in app(s): 'invitations' have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

And running makemigrations would create a migration like this:

operations = [
    migrations.AlterField(
        model_name='invitation',
        name='id',
        field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
    ),
]

But, naturally, this migration would be created in the packages installation directory (usually a virtualenv). Which is undesirable behavior.

There are ways to patch this from outside the lib, but maybe it would be a good idea to modify invitations/apps.py to look like this:

from django.apps import AppConfig


class Config(AppConfig):
    """Config."""

    default_auto_field = 'django.db.models.BigAutoField'
    name = "invitations"
    label = "invitations"
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

Successfully merging a pull request may close this issue.

2 participants