Issue #348 resolved

Latest Django trunk / Infinite loop caused by ordering.

Anonymous created an issue

Just upgraded to latest django head and application didn't work anymore. First had to apply patch from #331 so I had not to regenerate database but now I see the following error.

{{{ Environment:

Request Method: GET Request URL: http://localhost:8080/shop/ Django Version: 0.97-pre-SVN-7477 Python Version: 2.5.1 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.comments', 'comment_utils', 'django.contrib.sessions', 'django.contrib.sitemaps', 'django.contrib.sites', 'django.contrib.databrowse', 'satchmo.caching', 'satchmo.configuration', 'satchmo.shop', 'satchmo.contact', 'satchmo.product', 'satchmo.shipping', 'satchmo.payment', 'satchmo.discount', 'satchmo.giftcertificate', 'satchmo.supplier', 'satchmo.thumbnail', 'satchmo.l10n', 'satchmo.tax', 'satchmo.recentlist', 'satchmo.wishlist', 'satchmo.shipping.modules.tiered'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'satchmo.shop.SSLMiddleware.SSLRedirect', 'satchmo.recentlist.middleware.RecentProductMiddleware')

Template error: In template /home/ral/progs/shop/kabikaba/templates/base.html, error at line 39 Caught an exception while rendering: Infinite loop caused by ordering. 29 : <h3>{% trans "Search" %}</h3>

30 : <form id="search" action="{% url satchmo_search %}" method="get">

31 : <input type="text" size="20" name="keywords" id="search_keywords" /><br/>

32 : <input type="submit" value="{% trans "Search" %}" />

33 : </form>

34 : </div>

35 : <div>

36 : {% block sidebar %}

37 : <h3>{% trans "Shop Categories" %}</h3>

38 : <div id="menu_container">

39 : {% category_tree %}

40 : </div>

41 : {% endblock %}

42 : </div>

43 : </div>

44 :

45 : <div id="rightnav">

46 : <h3>{% trans "Account Information" %}</h3>

47 : {% if user.is_authenticated %}

48 : <a href="{% url satchmo_account_info %}">{% trans "Account Details" %}</a><br/>

49 : <a href="{% url auth_logout %}">{% trans "Log out" %}</a><br/>

Traceback: File "/home/ral/progs/shop/django_trunk/django/template/debug.py" in render_node 71. result = node.render(context) File "/home/ral/progs/shop/django_trunk/django/template/init.py" in render 871. return func(*resolved_vars) File "/home/ral/progs/shop/satchmo_trunk/satchmo/shop/templatetags/satchmo_category.py" in category_tree 52. for cats in Category.objects.filter(parent__isnull=True): File "/home/ral/progs/shop/django_trunk/django/db/models/query.py" in _result_iter 67. self._fill_cache() File "/home/ral/progs/shop/django_trunk/django/db/models/query.py" in _fill_cache 478. self._result_cache.append(self._iter.next()) File "/home/ral/progs/shop/django_trunk/django/db/models/query.py" in iterator 151. for row in self.query.results_iter(): File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py" in results_iter 182. for rows in self.execute_sql(MULTI): File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py" in execute_sql 1432. sql, params = self.as_sql() File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py" in as_sql 229. ordering = self.get_ordering() File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py" in get_ordering 564. self.model._meta, default_order=asc): File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py" in find_ordering_name 608. order, already_seen)) File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py" in find_ordering_name 602. raise FieldError('Infinite loop caused by ordering.')

Exception Type: FieldError at /shop/ Exception Value: Infinite loop caused by ordering.

}}}

When setup a new database an infinite loop - error comes, too.

{{{ Type 'yes' to load sample store data: yes Creating site... Creating Customers... Creating Suppliers... Creating Categories... Traceback (most recent call last): File "kabikaba/load_data.py", line 362, in <module> load_data() File "kabikaba/load_data.py", line 183, in load_data cat2.save() File "/home/ral/progs/shop/satchmo_trunk/satchmo/product/models.py", line 155, in save parents = self._recurse_for_parents(self) File "/home/ral/progs/shop/satchmo_trunk/satchmo/product/models.py", line 115, in _recurse_for_parents p = cat_obj.parent File "/home/ral/progs/shop/django_trunk/django/db/models/fields/related.py", line 221, in get rel_obj = self.field.rel.to._default_manager.get(params) File "/home/ral/progs/shop/django_trunk/django/db/models/manager.py", line 82, in get return self.get_query_set().get(*args, kwargs) File "/home/ral/progs/shop/django_trunk/django/db/models/query.py", line 181, in get num = len(clone) File "/home/ral/progs/shop/django_trunk/django/db/models/query.py", line 42, in len self._result_cache = list(self.iterator()) File "/home/ral/progs/shop/django_trunk/django/db/models/query.py", line 151, in iterator for row in self.query.results_iter(): File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py", line 182, in results_iter for rows in self.execute_sql(MULTI): File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py", line 1432, in execute_sql sql, params = self.as_sql() File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py", line 229, in as_sql ordering = self.get_ordering() File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py", line 564, in get_ordering self.model._meta, default_order=asc): File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py", line 608, in find_ordering_name order, already_seen)) File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py", line 602, in find_ordering_name raise FieldError('Infinite loop caused by ordering.') django.core.exceptions.FieldError: Infinite loop caused by ordering. }}}

Reported by alwin

Comments (6)

  1. Anonymous

    I hope this patch will fix it, also include same fix for admin. It's in satchmo/product/models.py, just a 2 lines edit adding __id (note the double underline).

    Index: models.py
    ===================================================================
    --- models.py	(revision 1155)
    +++ models.py	(working copy)
    @@ -186,10 +186,10 @@
     
         class Admin:
             list_display = ('name', '_parents_repr')
    -        ordering = ['parent', 'ordering', 'name']
    +        ordering = ['parent__id', 'ordering', 'name']
     
         class Meta:
    -        ordering = ['parent', 'ordering', 'name']
    +        ordering = ['parent__id', 'ordering', 'name']
             verbose_name = _("Category")
             verbose_name_plural = _("Categories")
    
  2. Anonymous

    I'd checked out latest trunk again, didn't help, but in admin-area when try editing categories

    Environment:
    
    Request Method: GET
    Request URL: http://localhost:8080/admin/product/category/
    Django Version: 0.97-pre-SVN-7481
    Python Version: 2.5.1
    Installed Applications:
    ['django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.comments',
     'comment_utils',
     'django.contrib.sessions',
     'django.contrib.sitemaps',
     'django.contrib.sites',
     'django.contrib.databrowse',
     'satchmo.caching',
     'satchmo.configuration',
     'satchmo.shop',
     'satchmo.contact',
     'satchmo.product',
     'satchmo.shipping',
     'satchmo.payment',
     'satchmo.discount',
     'satchmo.giftcertificate',
     'satchmo.supplier',
     'satchmo.thumbnail',
     'satchmo.l10n',
     'satchmo.tax',
     'satchmo.recentlist',
     'satchmo.wishlist',
     'satchmo.shipping.modules.tiered']
    Installed Middleware:
    ('django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.locale.LocaleMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.middleware.doc.XViewMiddleware',
     'satchmo.shop.SSLMiddleware.SSLRedirect',
     'satchmo.recentlist.middleware.RecentProductMiddleware')
    
    
    Traceback:
    File "/home/ral/progs/shop/django_trunk/django/core/handlers/base.py" in get_response
      82.                 response = callback(request, *callback_args, **callback_kwargs)
    File "/home/ral/progs/shop/django_trunk/django/contrib/admin/views/decorators.py" in _checklogin
      62.             return view_func(request, *args, **kwargs)
    File "/home/ral/progs/shop/django_trunk/django/views/decorators/cache.py" in _wrapped_view_func
      44.         response = view_func(request, *args, **kwargs)
    File "/home/ral/progs/shop/django_trunk/django/contrib/admin/views/main.py" in change_list
      772.         cl = ChangeList(request, model)
    File "/home/ral/progs/shop/django_trunk/django/contrib/admin/views/main.py" in __init__
      581.         self.query_set = self.get_query_set()
    File "/home/ral/progs/shop/django_trunk/django/contrib/admin/views/main.py" in get_query_set
      736.         qs = qs.order_by((self.order_type == 'desc' and '-' or '') + lookup_order_field)
    File "/home/ral/progs/shop/django_trunk/django/db/models/query.py" in order_by
      427.         obj.query.add_ordering(*field_names)
    File "/home/ral/progs/shop/django_trunk/django/db/models/sql/query.py" in add_ordering
      1293.             raise FieldError('Invalid order_by arguments: %s' % errors)
    
    Exception Type: FieldError at /admin/product/category/
    Exception Value: Invalid order_by arguments: ['product_category.parent']
    
  3. Anonymous

    ah, and following line I missed to insert into traceback:

    Installing xml fixture 'l10n_data' from '/home/ral/progs/shop/satchmo_trunk/satchmo/l10n/fixtures'.
    Problem installing fixture '/home/ral/progs/shop/satchmo_trunk/satchmo/l10n/fixtures/l10n_data.xml': Incorrect string value: '\xC5\x9Feron' for column 'name' at row 1
    
    
  4. Log in to comment