title: how to get user object and pass it to form field in django
body: <p>is there a better way to get the user object from the code below in <code>forms.py</code>?</p>
  <h1>models</h1>
  <pre><code>class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      ...
  </code></pre>
  <h1>forms.py</h1>
  <pre><code>class FooForm(forms.Form):
  
      def __init__(self, *args, **kwargs):
          self.request = kwargs.pop(&quot;user&quot;)
          super(ExperienceStart, self).__init__(*args, **kwargs)
          self.helper = FormHelper()
          self.helper.form_method = 'post'
          self.helper.layout = Layout(InlineRadios('topics'),)
  
      hardcoded_username = &quot;johndoe&quot; # i want to find a way not to hardcode this
  
      current_user = User.objects.filter(username=hardcoded_username).first()
  
      profile = Profile.objects.filter(user=current_user).first()
  
      ...
  
      profile_values = list(zip(profile, profile))
  
      profile = forms.TypedChoiceField(
          label=&quot;Select a Profile&quot;,
          choices=profile_values,
          coerce=str,
          widget=forms.RadioSelect,
          initial=profile[0],
          required=True)
  </code></pre>
  <h1>views.py</h1>
  <pre><code>def foo(request):
      form = fooForm(request.POST, user=request.user)
  
      print(form.request) # i have already tried this but i want to get it in form not views
  
      if request.method == &quot;POST&quot;:
          if form.is_valid():
              # do something
      else:
          form = fooForm(user=request.user)
  
      context = {&quot;form&quot;: form}
  </code></pre>
  <p>I am trying to find a way not to hardcode the username in <code>forms.py</code> and get the current logged in user.</p>