Ritu Singh
Problem:
I am trying to retrieve all bookings made by the logged-in user. I am getting the following error: Cannot assign "'Leonie": "Customer.user" must be a "User" instance. What I don't understand is how this is not an instance of the user model.
Views.py
models.py
I tried changing the foreign key constraint in the customer model to customer rather than user, however I am still getting the same error message. I'm sure there is a better way to accomplish retrieving all bookings by the user that is logged in.
Solution:
You should use request.user directly to retrieve the user object instead of request.user.username.
Answered by: >zankoAN
Credit: >Stackoverflow
Suggested reads:
>Fix webapp stops working issue in Django- Python webapp
>Creating a form in Django to upload a picture from website
>Sending Audio file from Django to Vue
>How to keep all query parameters intact when changing page in Django?
>Solved: TaskList View in Django