On Sun, Nov 15, 2009 at 4:35 PM, Malcolm MacKinnon <mmack3...@gmail.com>wrote:
> Hi, > > I'm new to django and am having a problem with the modelformset factory not > rendering all my form fields.For some odd reason, when I exclude the primary > key field, prim, it does not render this field in my template below. > {{form.m}}. When I do not exclude='prim', the field {{form.m}} is rendered > perfectly. In my view i have defined my formset as: > > Transpecform = modelformset_factory(Sotranspec, max_num=16, extra=16, > exclude='prim') > > Here's my view: > > def special_offers(request): > customer=request.session.get('customer') > c=request.session > c=c.items() > message='' > try: > order=Somastspec.objects.filter(custno=customer) > except: > pass > if request.method=='POST': > formset=Transpecform(request.POST, request.FILES, > queryset=Sotranspec.objects.none(), ) > if formset.is_valid(): > formset.save() > return HttpResponseRedirect('/home/') > else: > message='You have errors' > > else: > formset = Transpecform(queryset=Sotranspec.objects.none(), ) > return render_to_response('special_offers_step1.html', {'formset': > formset, 'customer':customer, 'c':c, 'message':message}, context_instance > = RequestContext(request)) > > Here's my template: > > <body> > > {% autoescape on %} > <img src="{{MEDIA_URL}}img/sporthillredblk.jpg" width="10%"/> > <div>SportHill Inc.</div> > <div>725 McKinley St.</div> > {{customer}} > <div>Eugene, OR 97402 USA</div> > {% ifnotequal message ''%} > <div id="message" style="background-color:cyan;">{{message}}</div> > {%endifnotequal%} > <form method="POST" action=""> > {{ formset.management_form }} > {% for form in formset.forms %} > <div id="hide"> {{ form.prim }} > {{ form.custno}}</div> > > <table> > <tr style="font-size:15px"><th>Select > Item</th><th>EA</th><th>XS</th><th>S</th><th>SL</th><th>SP</th><th>M</th><th>ML</th><th>MP</th><th>MS</th><th>L</th><th>LL</th><th>LP</th><th>LS</th><th>XL</th><th>XLL</th><th>XXL</th><th>SM</th><th>LXL</th><th>PLUS0</th><th>PLUS1</th><th>PLUS2</th><th>PLUS3</th><th>PLUS4</th><th>Total</th><th>Unit$</th><th>$Total</th></tr> > <tr><td>{{ form.item }}</td><td>{{ form.ea }}</td><td>{{ form.xs > }}</td><td>{{ form.s }}</td><td>{{ form.sl }}</td><td>{{ form.sp > }}</td><td>{{ form.m}}</td><td>{{ form.ml }}</td><td>{{ form.mp}}</td><td>{{ > form.ms }}</td><td>{{ form.l }}</td><td>{{ form.ll }}</td><td>{{ > form.lp}}</td><td>{{ form.ls }}</td><td>{{ form.xl }}</td><td>{{ > form.xll}}</td><td>{{ form.xxl }}</td><td>{{ form.sm }}</td><td>{{ > form.lxl}}</td><td>{{ form.plus0 }}</td><td>{{ form.plus1 }}</td><td>{{ > form.plus2 }}</td><td>{{ form.plus3 }}</td><td>{{ form.plus4 }}</td><td>{{ > form.total }}</td><td>{{ form.unit_price }}</td><td>{{ form.ext_price > }}</td> > </tr> > </table> > {% endfor %} > > <input type="submit" id="process" value="Process Order"></input> > </form> > {{custno}} > {% endautoescape %} > > > </body> > > Any thoughts or help would be very much appreciated. Thanks!. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.