Change Django Queryset to Dictionary


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def form_data(form, queryset):
  2. for field in form.base_fields.keys():
  3. data[field] = getattr(queryset, field)
  4. return data
  5.  
  6. data = form_data(YourForm, queryset)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.