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

class UserCreationForm(UserCreationForm):
    class Meta:
        model = User
        fields = ('username', 'password1', 'password2')

class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
        fields = ('bio', 'profile_image')

class UserRegistrationForm(UserCreationForm):
    email = forms.EmailField()
    class Meta(UserCreationForm.Meta):
        fields = UserCreationForm.Meta.fields + ('email',)

views.py
def profile(request):
    if request.method == 'POST':
        user_form = UserRegistrationForm(request.POST)
        profile_form = ProfileForm(request.POST, request.FILES)
        if user_form.is_valid() and profile_form.is_valid():
            user_form.save()
            profile_form.save()
            return redirect('home')
        else:
            print(user_form.errors, profile_form.errors)
    else:
        user_form = UserRegistrationForm()
        profile_form = ProfileForm()
    return render(request, 'profile.html', {'user_form':user_form, 'profile_form':profile_form})

# models.py
class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    bio = models.TextField(max_length=500, blank=True)
    profile_image = models.ImageField(upload_to='img/', blank=True, null=True)
    def __str__(self):
        return str(self.user)

forms.py
from django.contrib.auth.models import User
from .models import Profile

class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
        fields = ('bio', 'profile_image')

class UserRegistrationForm(UserCreationForm):
    email = forms.EmailField()
    class Meta(UserCreationForm.Meta):
        fields = UserCreationForm.Meta.fields + ('email',)

class UserCreationForm(UserCreationForm):
    class Meta:
        model = User
        fields = ('username', 'password1', 'password2')
```

I am trying to create a registration form in Django with a profile form that includes additional fields for user profile like bio and image. The registration form should handle both the user registration and the profile creation at the same time.

Here is the problem:

The issue seems to be with saving the profile form. It says that 'user' field is required. But I am not including it in the fields in the ProfileForm because it's automatically created with the user instance. I think the problem is that I am not linking the user instance created from user_form with the profile form. How do I do this?[/INST]