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

Set default_auto_field to 'AutoField' #223

Closed
simkimsia opened this issue Sep 16, 2021 · 5 comments · Fixed by #224
Closed

Set default_auto_field to 'AutoField' #223

simkimsia opened this issue Sep 16, 2021 · 5 comments · Fixed by #224

Comments

@simkimsia
Copy link
Contributor

simkimsia commented Sep 16, 2021

Django 3.2 introduces DEFAULT_AUTO_FIELD . If you set this to something other than 'django.db.models.AutoField', migrations will need to be generated for django-organization's models. This pull request sets default_auto_field just for these apps so that no migrations need to be generated.

It also hides warnings on Django 3.2.

The specific warning is

RemovedInDjango41Warning: 'organizations' defines default_app_config = 'organizations.apps.OrganizationsConfig'. Django now detects this configuration automatically. You can remove default_app_config.
    app_config = AppConfig.create(entry)

Similar in another highly used django library pennersr/django-allauth#2829

EDIT

Change allauth to django-organization

simkimsia added a commit to simkimsia/django-organizations that referenced this issue Sep 16, 2021
This will avoid warnings in Django 3.2 and will avoid the creation of new migrations.

closed bennylope#223
@simkimsia
Copy link
Contributor Author

simkimsia commented Sep 16, 2021

For those who are looking for workaround while waiting for the PR #224 to be merged, here's the workaround.

GO to your apps.py in your django project and add this at the end of the file. Do remember to remove it after the PR is merged

from organizations.apps import OrganizationsConfig


class ModifiedOrganizationsConfig(OrganizationsConfig):
    default_auto_field = "django.db.models.AutoField"

in your settings.py where you declare your third_party_apps

THIRD_PARTY_APPS = [
    ...
    # "organizations", # you should comment this out and when the PR is merged, uncomment it
    "yourproject.apps.ModifiedOrganizationsConfig", # remove this when PR is merged
    ....
]

LOCAL_APPS = [
    "yourprojectapp",
]

# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

@bennylope
Copy link
Owner

I was very confused by this:

Django 3.2 introduces DEFAULT_AUTO_FIELD . If you set this to something other than 'django.db.models.AutoField', migrations will need to be generated for allauth's models. This pull request sets default_auto_field just for these apps so that no migrations need to be generated.

But that if that reads "django-organization's models" then it makes a lot more sense!

Thank you @simkimsia!

@simkimsia
Copy link
Contributor Author

But that if that reads "django-organization's models" then it makes a lot more sense!

Oh right.. sorry!

@simkimsia
Copy link
Contributor Author

@bennylope pls update pypi for a new version if you don't mind. I like to update the dependency so i can stop using the workard i detailed here.

@bennylope
Copy link
Owner

@simkimsia it's live now, thank you again https://pypi.org/project/django-organizations/#history

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