views.py

def what(request):
    ' ' ' '
    ' ' ' '
    if request.method == 'POST':
        ReportType.objects.filter(report=report).delete()
        checked_ones = [unicode(x) for x in subtype if unicode(x) in 
request.POST.keys()]
        for entry in checked_ones:
            r = ReportType()
            r.report = report 
            r.title = entry
            r.save()
        return redirect('/member/where/')
    checked_ones = [x.title for x in ReportType.objects.filter(report=report)]  
    return render(request, 'incident/what.html',
    {
    'typeList':list,
    'checked_ones':checked_ones,
     })
 

template

{% for type in typeList%}
  {% if type.parent_type_id == None %}
   <h1>{{type.title}}</h1>
  {% else %}
  <label><input type="checkbox" checked="true" name="{{type.title}}">{{ 
type.title }}</label><br /> 
  {% endif %}{% endfor %}


Here i am listing parent element and inside the parent element i am 
populating their child element.Problem is only last populated parent 
element's child is saving,rest of the other is not saving in db.Need help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to