Wednesday, April 5, 2017

after upgrade to django 1.11 from 1.10.6 getting an exception on runserver

Traceback (most recent call last):
   File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/apps/registry.py", line 116, in populate
    app_config.ready()
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 23, in ready
    self.module.autodiscover()
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
    import_module('%s.%s' % (app_config.name, module_to_search))
  File "/usr/lib/python2.7/importlib/__init__.py", line 38, in import_module
    __import__(name)
  File "/srv/webapps/myproj.com/myproj/product/admin.py", line 6, in <module>
    from product.forms import ProductChangeLogFilterForm, PopularBrandAdminForm
  File "/srv/webapps/myproj.com/myproj/product/forms.py", line 124, in <module>
    class CatAdminForm(forms.ModelForm):
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/forms/models.py", line 252, in __new__
    opts.field_classes)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/forms/models.py", line 177, in fields_for_model
    formfield.queryset = formfield.queryset.complex_filter(limit_choices_to)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/db/models/query.py", line 814, in complex_filter
    clone.query.add_q(filter_obj)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1260, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
  File "/srv/webapps/myproj.com/virtualenvs/myproj1.11/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1275, in _add_q
    joinpromoter = JoinPromoter(q_object.connector, len(q_object.children), current_negated)
AttributeError: LimitTagAssociations instance has no attribute 'children'




class LimitTagAssociations():
    def __init__(self, criteria):
        self.criteria = criteria

    def add_to_query(self, query, aliases):
        query.add_q(models.Q(id__in=[1, 2, 3]))
        query.distinct = True


class Cat(models.Model):
    new_and_now_reco_base = fields.IntegerRangeField(min_value=500, max_value=10000, default=1000)
    auto_taggroups = models.ManyToManyField(TagGroup, null=True, blank=True, limit_choices_to=LimitTagAssociations('1'))
    manual_taggroups = models.ManyToManyField(TagGroup, null=True, blank=True, limit_choices_to=LimitTagAssociations('2'))
    abs_url = models.CharField(max_length=255, blank=True, null=True)
    primary_filter_select = models.ManyToManyField(TagGroup, null=True, blank=True, limit_choices_to=LimitTagAssociations('3'))

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ecdb0544-ad67-4b4f-8380-6c109253bf6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment