Django Forms and Models

I have a function based view:

@login_required def profile(request): if request.method == 'POST':     form = IngredientForm(request.POST, user=request.user)     if form.is_valid():         ingredient_1 = form.cleaned_data['ingredient_1']         ingredient_2 = form.cleaned_data['ingredient_2']         ingredient_3 = form.cleaned_data['ingredient_3']         ingredient_4 = form.cleaned_data['ingredient_4']         ingredient_5 = form.cleaned_data['ingredient_5']         messages.success(request, f'Ingredients added to your account!')         return redirect('profile') else:     form = IngredientForm(user=request.user) return render(request, 'users/profile.html', {'form': form}) 

and the model is:

from django.db import models from django.contrib.auth.models import User  class ingredients(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) ingredient_1 = models.CharField(max_length=32) ingredient_2 = models.CharField(max_length=32) ingredient_3 = models.CharField(max_length=32) ingredient_4 = models.CharField(max_length=32) ingredient_5 = models.CharField(max_length=32) looks like:

class IngredientForm(forms.ModelForm): def __init__(self, *args, **kwargs):     self.user = kwargs.pop('user', None)     super(IngredientForm, self).__init__(*args, **kwargs) class Meta:     model = ingredients     fields = ('ingredient_1', 'ingredient_2', 'ingredient_3', 'ingredient_4', 'ingredient_5') 

I am trying to get the current user and use that as the key for the ingredients table in my database. I am not sure how to get the current user and set the user in the table as the current user. Any help would be appreciated 🙂