D
D
dimas75252018-05-16 17:09:07
Django
dimas7525, 2018-05-16 17:09:07

How to autocomplete the ForeignKey of the username field in a form?

There is a form to leave a message.
How to make the username field automatically populated with the username of the currently logged in user?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Astrohas, 2018-05-16
@Astrohas

<input name='user' value={{request.user.username}} >
but it's safer to do it on the backend side

T
tema_sun, 2018-05-16
@tema_sun

google -> django forms initial data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question