This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I am new to Django and trying to learn how to build websites by playing around with a small project of my own.
How can I add the current logged in username as a field named "added_by" in my model? Below is my example model for reference. I have spent the last several hours trying to get this to work but in vain. I am looking forward to your help and support as I am currently clueless about this step.
UPDATE: Just to give a simple explanation, I am trying to create a simple Phonebook where a user can signup and login (required), add/update/delete contacts. For that I have created two apps - contacts and users. The contacts app handles everything related to adding/deleting/updating a user's contacts for which I have created a Contact model. The users app handles everything related to sign up, login and logout and I have created a separate Profile model for it.
Currently, the sign ups, logins and logouts work well. I am also able to add new contacts to my profile after signing in too. But the problem is, I am seeing contacts added by all users and not specific to the ones only I added. For this very reason, I want to add a username column to the Contact Model using which I can filter out all contacts relative to the person who has signed in. Hope this gives some clarity on what I am doing.
P.S. I am new to Django. This is just my learn on the job kind of project. Kindly bear with me if I do not understand everything.. :-)
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/django/comm...