Skip to content Skip to sidebar Skip to footer

Django: How To Pre-populate A Form When Using Non-model Data?

In my case, the Django app is saving and getting user data to/from an external service via an API. I get an object with a number of user attributes, e.g. name, address, etc. For u

Solution 1:

Use initial to declare the initial value of form fields at runtime. For example, you might want to fill in a username field with the username of the current session.

f = ContactForm(initial={'subject': 'Hi there!'})

Post a Comment for "Django: How To Pre-populate A Form When Using Non-model Data?"