Note that there are some explanatory texts on larger screens.

plurals
  1. POAutocomplete-light not loading select list
    text
    copied!<p>I'm trying to get autocomplete-light working in the admin area of my app. The docs are located here: </p> <ul> <li><a href="http://django-autocomplete-light.readthedocs.org/en/docs_rewrite/debug.html" rel="nofollow">http://django-autocomplete-light.readthedocs.org/en/docs_rewrite/debug.html</a></li> </ul> <p>The Foreign Key select list is dissapearing and a basic text box is appearing as expected. But the select list is not showing up.</p> <p>I have installed the app and placed the appropriate include in my urls.py.</p> <p>related models:</p> <pre><code>class Inventory(models.Model): title = models.CharField(max_length=100, db_index=True) product_code = models.CharField(max_length=100, db_index=True, primary_key = True) class Customer_Order(models.Model): order_id = models.CharField(max_length=100, db_index=True, null = True, blank = True) customer_id = models.ForeignKey('inventory.Customer') products = models.ManyToManyField('inventory.Inventory', through='inventory.Customer_Order_Products') class Customer_Order_Products(models.Model): order_id = models.ForeignKey('inventory.Customer_Order') product_id = models.ForeignKey('inventory.Inventory') </code></pre> <p>autocomplete_light_registry.py:</p> <pre><code>import autocomplete_light from inventory.models import Inventory autocomplete_light.register(Inventory, search_fields=('title',), autocomplete_js_attributes={'placeholder': 'city name ..'}) </code></pre> <p>admin.py:</p> <pre><code>class Customer_Order_ProductsInline(enhanced_admin.EnhancedAdminMixin, admin.TabularInline): model = Customer_Order.products.through extra = 0 form = autocomplete_light.modelform_factory(Customer_Order_Products) class Customer_OrderAdmin(enhanced_admin.EnhancedModelAdminMixin, admin.ModelAdmin): inlines = (Customer_Order_ProductsInline, OrderStatusInline ) </code></pre> <p>My own debugging:</p> <ul> <li><p>I've gone to /autocomplete/ and found the registered list of Inventory titles, however it is not complete. It is only showing about 20 of them out of 155.</p></li> <li><p>I've made sure that the proper files are being loaded in the html. All of the includes appear to be showing up. I get a 304 code in the terminal for all of them, but I think this is okay. The only thing I can't seem to ensure that is being loaded is the link to jquery. I found the link to the script in the header of the html source, and checked the link (https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js) which appears to work.</p></li> </ul> <p>UPDATED **</p> <ul> <li><p>I just found this error in the web developer error console: TypeError: 'undefined' is not a function (evaluating '$(this).yourlabsWidget()') in widget.js on line 297. This shows that at least widget.js is being loaded.</p></li> <li><p>And finally, when I update an existing Customer_Order, the blank field shows up NEXT to the regular foreign key pull down. Not inplace of it. I have no idea why this is happening.</p></li> </ul> <p>I was hoping someone has either had a similar issue, or has some debugging advice. I'm fairly new to Django and my debugging skills are lacking at best.</p> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en-us" &gt; &lt;head&gt; &lt;title&gt;Add Customer Order | Art &amp; Fibre&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css" /&gt; &lt;!--[if lte IE 7]&gt;&lt;link rel="stylesheet" type="text/css" href="/static/admin/css/ie.css" /&gt;&lt;![endif]--&gt; &lt;script type="text/javascript"&gt;window.__admin_media_prefix__ = "/static/admin/"; &lt;/script&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/static/autocomplete_light/autocomplete.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/static/autocomplete_light/widget.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/static/autocomplete_light/addanother.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/static/autocomplete_light/text_widget.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/static/autocomplete_light/remote.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="/static/autocomplete_light/style.css" /&gt; </code></pre> <p>then later on..</p> <pre><code>&lt;span class="autocomplete-light-widget customer_order_products_set-0-product_id single" id="id_customer_order_products_set-0-product_id-wrapper" data-max-values="1" data-bootstrap="normal" data-autocomplete-url="/autocomplete/InventoryAutocomplete/" data-autocomplete-choice-selector="[data-value]" data-autocomplete-placeholder="Product name .." &gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload