<s>[INST] from django import forms
from django.contrib.auth.models import User
from .models import Group, Profile

class UserAuthForm(forms.Form):
    email = forms.EmailField(max_length=100)
    password = forms.CharField(widget=forms.PasswordInput, max_length=100)
    username = forms.CharField(max_length=100)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['email'].required = False

    def clean(self):
        cleaned_data = super().clean()
        if cleaned_data['username']:
            try:
                User.objects.get(username=cleaned_data['username'])
                self.add_error('username', 'Username already exists')
            except User.DoesNotExist:
                pass

        if cleaned_data['email']:
            try:
                User.objects.get(email=cleaned_data['email'])
                self.add_error('email', 'Email already exists')
            except User.DoesNotExist:
                pass

class UserAuthForm(forms.ModelForm):
    class Meta:
        model = User
        fields = ('username', 'email')

    email = forms.EmailField(max_length=100)
    password = forms.CharField(widget=forms.PasswordInput, max_length=100)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['email'].required = False

    def clean(self):
        cleaned_data = super().clean()
        if cleaned_data['username']:
            try:
                User.objects.get(username=cleaned_data['username'])
                self.add_error('username', 'Username already exists')
            except User.DoesNotExist:
                pass

        if cleaned_data['email']:
            try:
                User.objects.get(email=cleaned_data['email'])
                self.add_error('email', 'Email already exists')
            except User.DoesNotExist:
                pass
```

Here are my two versions of the form. Can someone help me clean up and provide feedback on this code?[/INST]