Re: Can't get initial value into form correctly.

2016-05-14 Thread Stephen J. Butler
It's now a dict, so you have to index into it. The for loop won't magically know which element of add_product_forms you want. You'd want add_product_forms[item.pk]. But ugg... apparently Django templates won't (out of the box) let you index a dict using another variable. Thanks for reminding me

Re: Can't get initial value into form correctly.

2016-05-14 Thread Chris Kavanagh
Yeah, I'm obviously doing something wrong in the template, Stephen. I'm not quite sure what I'm supposed to do (in the template). You kinda lost me on the last sentence, "Then adjust your template to index into add_product_forms based on item.pk." Could you give me a hint, please? And thank you

Re: Can't get initial value into form correctly.

2016-05-14 Thread Chris Kavanagh
Thank for the answer, Stephen. However, I'm still a little confused, and it apparently doesn't' work unless I'm doing something wrong in the template. In the template, I'm supposed to change the "add_product_form" to "add_product_forms" in the template? In other words, "add_product_forms.quantity"

Re: Can't get initial value into form correctly.

2016-05-14 Thread Stephen J. Butler
You assign to context every loop iteration. So at the end, only the last add_product_form constructed is ever used. Try this: def show_cart(request): cart_id = _cart_id(request) cart_items = CartItem.objects.filter(cart_id=cart_id) add_product_forms = {} for item in cart_items:

modelformset_factory generating "object has no attribute instance" error

2016-05-14 Thread Farhan Khan
I am trying to display a modelformset_factory in a view, but am running into this error and unable to figure out why. builtins.AttributeError AttributeError: 'IPAddressForm' object has no attribute 'instance' This seems to happen when I include this in my view: {{ ipaddressformset.as_table }}

Can't get initial value into form correctly.

2016-05-14 Thread Chris Kavanagh
I'm working on an online shop, and I'm having a problem in the cart, here's a screen shot (http://pasteboard.co/Vwnv2T0.png). I'd like the form for each item (product) to show it's current quantity (that's already been added to the cart) as an initial value as most ecommerce sites do. I've

Re: iterations of a list

2016-05-14 Thread James Schneider
On May 14, 2016 1:19 PM, "Shu Latif" wrote: > > It's this line in names(ftes) > > results = conn.search_s("o=domain.com", ldap.SCOPE_SUBTREE, "uid=" + ftes, attrlist=['gecos']) > getFTE() can return with a string or with a list. You are using that value for ftes when

Re: iterations of a list

2016-05-14 Thread Shu Latif
It's this line in names(ftes) results = conn.search_s("o=domain.com", ldap.SCOPE_SUBTREE, "uid=" + ftes, attrlist=['gecos']) On Saturday, May 14, 2016 at 1:00:22 AM UTC-7, James Schneider wrote: > > > On May 13, 2016 6:34 PM, wrote: > > > > I'm basically trying to

A question on save_m2m()

2016-05-14 Thread Ankush Thakur
So the following section from the docs has me a little confused: = Another side effect of using commit=False is seen when your model has a many-to-many relation with another model. If your model has a many-to-many relation and you specify commit=False when you save a form,

Re: 1.8 or 1.9?

2016-05-14 Thread Ankush Thakur
I've done the official tutorial and the Django Girls tutorial (I like the latter better ^.^) but now want to learn to build something nontrivial. I saw a thread on Reddit that talked about frustrations arising from minor inconsistencies between libraries and non-LTS releases. What would be your

Re: 1.8 or 1.9?

2016-05-14 Thread Ankush Thakur
Thank you, Florian! :-) Indeed, stability and job market are what's on my mind. It's comforting to know what I can stick to LTS versions and be assured of (almost 100%) stability. Just another minor concern: What if, say, the other minor upgrade rolls out a really cool feature that takes out a

Re: iterations of a list

2016-05-14 Thread James Schneider
On May 13, 2016 6:34 PM, wrote: > > I'm basically trying to get employees of a manger using ldap. The error I get is TypeError at /aboutus-test/ cannot concatenate 'str' and 'list' objects. I think the issue is it's taking the list of employees and trying to put them all into

Re: Djnago 1.9.5 with SQL SERVER 2012 connect??

2016-05-14 Thread Mandeep Tondak
Thanks Nikolas. Sent with MailTrack On Fri, May 13, 2016 at 10:44 PM, Nikolas Stevenson-Molnar < nik.mol...@consbio.org> wrote: > It looks like djano_pyodbc doesn’t support Django 1.9 yet: >