[Answer]-Add value to database without using forms in django

0👍

get the article instance first, commit explained in docs

article = form.save(commit=False)

then assign the author

article.Author = request.user 

creating an Author field will automatically create an Author_id field in your table. I think if you create your field named Author_id it could create an Author_Id_id field? It’s safer in some ways to work with objects ie ‘User’ instance then it is to work with integers ie user.id

article.save()

1👍

Change
Author_id = models.CharField(max_length=3)
to
Author = models.ForeignKey(User)

Then do what dm03514 is suggesting

Leave a comment