Answer the question
In order to leave comments, you need to log in
How to determine the author of an article in Django?
There is an article model in which the Author field is the user who creates it.
author = models.ForeignKey(User, related_name='author', on_delete=models.CASCADE)
Answer the question
In order to leave comments, you need to log in
In general, the article model should have an "author" column
if request.user is authenticated:
Statya.objects.create(title=title,text=text,author= request.user.id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question