Hello, I’m using the cookiecutter project with email as the required login, but I’m not sure how to query the user correctly. Snippets of my code below.
Settings (base.py)
AUTH_USER_MODEL = "users.User"
Model
from django.conf import settings
create_user_id = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE,verbose_name = "Create User ID")
View/form
from django.contrib.auth import get_user_model
User = get_user_model()
self.fields['create_user_id'] = request.user ###DOESN'T WORK
self.fields['create_user_id'] = User.objects.get(email=request.user) ###DOESN'T WORK
Error
'User' object has no attribute 'get_bound_field'
What is the appropriate way to get the user? Do I have the right settings in the model? Ultimately I need to save the user with the model form.
Appreciate any help, thank you!