Python django.db.models.sql.query.LOOKUP_SEP() Examples

The following are code examples for showing how to use django.db.models.sql.query.LOOKUP_SEP(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: blog_django   Author: chnpmy   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = field.remote_field.name
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 2
Project: dream_blog   Author: fanlion   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 3
Project: MxOnline   Author: myTeemo   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 4
Project: djangoblog   Author: liuhuipy   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 5
Project: sdining   Author: Lurance   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 6
Project: xadmin-markdown-editor   Author: bluenknight   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 7
Project: eduDjango   Author: yuzhou6   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 8
Project: Django-IMOOC-Shop   Author: LBruse   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 9
Project: StudyOnline   Author: yipwinghong   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 10
Project: Django-shop   Author: poetries   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 11
Project: MoocOnline   Author: My-captain   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 12
Project: followme   Author: wzqnls   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 13
Project: mxonline   Author: huwei86   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 14
Project: Charlotte   Author: LiZoRN   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 15
Project: imooc-django   Author: zaxlct   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 16
Project: muxueonline   Author: 124608760   File: relate.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception(u'Relate Lookup field must a related field')

        self.to_model = field.related_model
        self.rel_name = '__'.join(parts[1:])
        self.is_m2m = bool(field.many_to_many)

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 17
Project: YouPBX   Author: JoneXiong   File: relate.py    (license) View Source Project 5 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field_by_name(parts[0])[0]

        if not hasattr(field, 'rel') and not isinstance(field, RelatedObject):
            raise Exception(u'Relate Lookup field must a related field')

        if hasattr(field, 'rel'):
            self.to_model = field.rel.to
            self.rel_name = field.rel.get_related_field().name
            self.is_m2m = isinstance(field.rel, models.ManyToManyRel)
        else:
            self.to_model = field.model
            self.rel_name = self.to_model._meta.pk.name
            self.is_m2m = False

        _manager = self.to_model._default_manager
        if hasattr(_manager, 'get_query_set'):
            to_qs = _manager.get_query_set()
        else:
            to_qs = _manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 18
Project: xadmin_python3   Author: mahongquan   File: relate.py    (license) View Source Project 5 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not is_related_field2(field):
            raise Exception('Relate Lookup field must a related field')

        if hasattr(field, 'rel'):
            self.to_model = field.rel.to
            self.rel_name = field.rel.get_related_field().name
            self.is_m2m = isinstance(field.rel, models.ManyToManyRel)
        else:
            self.to_model = field.model
            self.rel_name = self.to_model._meta.pk.name
            self.is_m2m = False

        to_qs = self.to_model._default_manager.get_queryset()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field 
Example 19
Project: mes   Author: osess   File: relate.py    (license) View Source Project 5 votes vote down vote up
def __init__(self, admin_view, lookup, value):
        self.admin_view = admin_view
        self.org_model = admin_view.model
        self.opts = admin_view.opts
        self.lookup = lookup
        self.value = value

        parts = lookup.split(LOOKUP_SEP)
        field = self.opts.get_field(parts[0])

        if not hasattr(field, 'rel') and not isinstance(field, RelatedObject):
            raise Exception(u'Relate Lookup field must a related field')

        if hasattr(field, 'rel'):
            self.to_model = field.rel.to
            self.rel_name = field.rel.get_related_field().name
            self.is_m2m = isinstance(field.rel, models.ManyToManyRel)
        else:
            self.to_model = field.model
            self.rel_name = self.to_model._meta.pk.name
            self.is_m2m = False

        to_qs = self.to_model._default_manager.get_query_set()
        self.to_objs = to_qs.filter(**{self.rel_name: value}).all()

        self.field = field