Binding Issue with initial model

41 views
Skip to first unread message

Chad Files

unread,
Dec 10, 2012, 5:04:52 PM12/10/12
to django-s...@googlegroups.com
I have a very specific issue that has taken we weeks to reliably diagnose/replicate. It only occurs when I have a model form with initial values. Often when the form is loaded the "selected item" comes back as None. The item does exist and I can work around it by by clicking the list icon (displays the options) and refreshing the page. It appears to me that when the initial item is loaded it cannot be found in the JSON from the lookup. When I force the JSON to reload and refresh the correct item is found. So...is there a way to force the item to be looked-up? Is this a caching issue (I am using Apache with mod_wsgi)? Any help will be appreciated.

Mark Lavin

unread,
Dec 10, 2012, 7:16:07 PM12/10/12
to django-s...@googlegroups.com
The JS appends the current timestamp to the query string to avoid an browser caching so I would not expect this to be a caching issue unless you have some additional caching layers. There was a similar sounding issue related to the Django admin auto-focusing on the first field https://bitbucket.org/mlavin/django-selectable/issue/34/. Other than that I've used selectable in a number of forms which pre-populate a selected item and I can't say I've seen this issue myself.

Best,

Mark

Chad Files

unread,
Dec 11, 2012, 7:46:54 AM12/11/12
to django-s...@googlegroups.com
I found more information last night...

First off, I have several selectables on the screen (no less than 5 - more sometimes because of an inline-formset). Many of my lists have names (Last, First) in them. When my form has an item that starts at the top of the alphabet (Abbot, Joe) it works fine. When my item has a name at the end of the alphabet (Zimmer, Jane) that is when I get the "None". The strange thing is, if the first selectable does not find it's item, none of them do. The workaround sequence I mentioned in my original post makes it work again.

I do think I am forcing an autofocus, so I will look into the link you sent. Thanks!

Mark Lavin

unread,
Dec 11, 2012, 8:31:00 AM12/11/12
to django-s...@googlegroups.com
Is this a dynamic inline formset? There are some issues with the popular django-dynamic-formset which can be worked around https://django-selectable.readthedocs.org/en/version-0.6.2/advanced.html#dynamically-added-forms. It has to do with how/when the plugin does the element clone.

In any case I hope the autofocus route finds something for you because this sounds like quite a strange issue.

-Mark
Reply all
Reply to author
Forward
0 new messages