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

Fix django 4.2 incompatability #629

Merged
merged 7 commits into from
Apr 25, 2023
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
'beautifulsoup4~=4.9',
'django>=3.1,<5.0', # TOM Toolkit requires db math functions
'djangorestframework~=3.12',
'django-bootstrap4>=3,<23',
'django-bootstrap4>=3,<24',
'django-contrib-comments~=2.0', # Earlier version are incompatible with Django >= 3.0
'django-crispy-forms~=2.0',
'crispy-bootstrap4',
'django-extensions~=3.1',
'django-filter>=21,<23',
'django-filter>=21,<24',
'django-gravatar2~=1.4',
'django-guardian~=2.3',
'fits2image>=0.4.2',
Expand Down
11 changes: 10 additions & 1 deletion tom_common/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm, UsernameField
from django.contrib.auth.forms import UsernameField
from django.contrib.auth.models import User, Group

# UserCreationForm was changed for django 4.2 to not allow new users to have case-sensitive variations in
# existing usernames. This check breaks our username update process because we use the UserCreationForm rather
# than directly updating an existing user. The BaseUserCreationForm of Django 4.2 is identical to earlier
# versions of UserCreationForm. (https://docs.djangoproject.com/en/4.2/releases/4.2/#miscellaneous)
try:
from django.contrib.auth.forms import BaseUserCreationForm as UserCreationForm
except ImportError:
from django.contrib.auth.forms import UserCreationForm


class ChangeUserPasswordForm(forms.Form):
password = forms.CharField(widget=forms.PasswordInput())
Expand Down