Wednesday, April 5, 2017

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

query.add_q() is a private API. I'd suggest to use git bisect to find the Django commit where the behavior changed. That might give you a hint of how to adapt your code.

On Wednesday, April 5, 2017 at 11:25:25 AM UTC-4, Mukul Acharya wrote:
Traceback (most recent call last):
    fn(*args, **kwargs)
    autoreload.raise_last_exception()
    six.reraise(*_exception)
    fn(*args, **kwargs)
    apps.populate(settings.INSTALLED_APPS)
    app_config.ready()
    self.module.autodiscover()
    autodiscover_modules('admin', register_to=site)
    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):
    opts.field_classes)
    formfield.queryset = formfield.queryset.complex_filter(limit_choices_to)
    clone.query.add_q(filter_obj)
    clause, _ = self._add_q(q_object, self.used_aliases)
    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/68cc9293-cc83-4fbd-a20f-9c1b2f8b99b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment