python - django model instance in form without model -


i have form say:

class profileeditform(forms.form):     first_name = forms.charfield(max_length=20)     last_name = forms.charfield(max_length=20)     email = forms.emailfield(max_length=50)     address = forms.charfield(max_length=100) 

i want pass model instance on when user tries edit profile existing data on form.

for reasons not using modelform

lets have instance user = user.objects.get(pk=pk)

and want pass instance form = profileeditform(instance=user)

i googled , found can use instance model form can use in form not model ?

thank you

try this:

user = user.objects.filter(pk=pk).values('first_name','last_name','email','address') form = profileeditform(user[0]) 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -