• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python modelsinspector.add_ignored_fields函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中south.modelsinspector.add_ignored_fields函数的典型用法代码示例。如果您正苦于以下问题:Python add_ignored_fields函数的具体用法?Python add_ignored_fields怎么用?Python add_ignored_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了add_ignored_fields函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _

    ('VC', _('St. Vincent & the Grenadines')),
    ('VE', _('Venezuela')),
    ('VG', _('British Virgin Islands')),
    ('VI', _('United States Virgin Islands')),
    ('VN', _('Viet Nam')),
    ('VU', _('Vanuatu')),
    ('WF', _('Wallis & Futuna Islands')),
    ('WS', _('Samoa')),
    ('YE', _('Yemen')),
    ('YT', _('Mayotte')),
    ('YU', _('Yugoslavia')),
    ('ZA', _('South Africa')),
    ('ZM', _('Zambia')),
    ('ZR', _('Zaire')),
    ('ZW', _('Zimbabwe')),
    ('ZZ', _('Unknown or unspecified country')),
)

class CountryField(models.CharField):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault('max_length', 2)
        kwargs.setdefault('choices', COUNTRIES)

        super(CountryField, self).__init__(*args, **kwargs)

    def get_internal_type(self):
        return "CharField"

from south.modelsinspector import add_ignored_fields 
add_ignored_fields(["^webEval\.web_eval__core\.fields.CountryField"]) 
开发者ID:hadesgames,项目名称:webEval,代码行数:30,代码来源:fields.py


示例2: CommentsRelation

class CommentsRelation(GenericRelation):
    """
    A :class:`~django.contrib.contenttypes.generic.GenericRelation` which can be applied to a parent model that
    is expected to have comments. For example:

    .. code-block:: python

        class Article(models.Model):
            comments_set = CommentsRelation()
    """
    def __init__(self, *args, **kwargs):
        super(CommentsRelation, self).__init__(
            to=get_comments_model(),
            content_type_field='content_type',
            object_id_field='object_pk',
            **kwargs
        )


try:
    from south.modelsinspector import add_ignored_fields
except ImportError:
    pass
else:
    # South 0.7.x ignores GenericRelation fields but doesn't ignore subclasses.
    # Taking the same fix as applied in http://south.aeracode.org/ticket/414
    _name_re = "^" + __name__.replace(".", "\.")
    add_ignored_fields((
        _name_re + "\.CommentsRelation",
    ))
开发者ID:MrTomato8,项目名称:django-fluent-comments,代码行数:30,代码来源:models.py


示例3: TaggableManager

from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _

from taggit.forms import TagField
from taggit.managers import TaggableManager as BaseTaggableManager

from widgets import TagAutocomplete


class TaggableManager(BaseTaggableManager):
    def formfield(self, form_class=TagField, **kwargs):
        defaults = {
            "label": capfirst(self.verbose_name),
            "help_text": _("A comma-separated list of tags."),
            "required": not self.blank,
        }
        defaults.update(kwargs)

        defaults['widget'] = TagAutocomplete

        return form_class(**defaults)

# South introspection rule
try:
    from south.modelsinspector import add_ignored_fields
    add_ignored_fields(["^taggit_autocomplete\.managers"])
except ImportError:
    pass
开发者ID:isi-gach,项目名称:django-taggit-jquery-tag-it,代码行数:28,代码来源:managers.py


示例4: is_installed

elif is_installed('taggit'):
    from taggit.managers import TaggableManager as BaseTaggableManager
else:
    BaseTaggableManager = None


# Make sure the 'tags' field is ignored by old versions of South
try:
    from south.modelsinspector import add_ignored_fields
except ImportError:
    pass
else:
    # South should ignore the tags field as it's a RelatedField.
    add_ignored_fields((
        "^taggit\.managers\.TaggableManager",
        "^taggit_selectize\.managers\.TaggableManager",
        "^taggit_autosuggest\.managers\.TaggableManager",
        "^taggit_autocomplete_modified\.managers\.TaggableManagerAutocomplete",
    ))


if BaseTaggableManager is not None:
    # Make sure the migrations have one consistent path to import from
    class TaggableManager(BaseTaggableManager):
        pass
else:
    class TaggableManager(Field):
        def __bool__(self):
            return False  # partial compatibility with old code.

        def __nonzero__(self):
            return False  # Python 2
开发者ID:django-fluent,项目名称:django-fluent-utils,代码行数:32,代码来源:taggit.py


示例5: RGBColorField

import re

from django.db.models import CharField
from django.forms.fields import RegexField

from widgets import ColorFieldWidget

RGB_REGEX = re.compile('^#?([0-F]{3}|[0-F]{6})$', re.IGNORECASE)

class RGBColorField(CharField):
    
    widget = ColorFieldWidget
    
    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = 7
        super(RGBColorField, self).__init__(*args, **kwargs)
        
    def formfield(self, **kwargs):
        kwargs.update({
                       'form_class': RegexField,
                       'widget': self.widget,
                       'regex': RGB_REGEX
                       })
        return super(RGBColorField, self).formfield(**kwargs)

try:
    from south.modelsinspector import add_ignored_fields
    add_ignored_fields(['^colorful\.fields'])
except ImportError:
    pass
开发者ID:bollwyvl,项目名称:django-colorful,代码行数:30,代码来源:fields.py


示例6: add_ignored_fields

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
#from mptt.models import MPTTModel, TreeForeignKey
from django.utils.safestring import mark_safe
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.generic import GenericForeignKey
from coop_tag.settings import get_class, TAGGER_FKEY_NAME
from django.conf import settings
from django.db import router
import re

import slugify

try:
    from south.modelsinspector import add_ignored_fields
    add_ignored_fields(["^coop_tag\.managers"])
except ImportError:
    pass  # without south this can fail silently


class TagBase(models.Model):
    name = models.CharField(verbose_name=_('Name'), max_length=100)
    slug = models.SlugField(verbose_name=_('Slug'), unique=True, max_length=100)
    # parent = TreeForeignKey('self', null=True, blank=True, related_name='children')

    def __unicode__(self):
        return self.name

    # class MPTTMeta:
    #     order_insertion_by = ['name']
开发者ID:apalazon,项目名称:coop-tag,代码行数:30,代码来源:models.py


示例7: AbstractTranslatableEntry

class AbstractTranslatableEntry(
    AbstractTranslatableEntryBase, ContentsEntryMixin, CommentsEntryMixin, CategoriesEntryMixin, TagsEntryMixin
):
    """
    The default entry model for translated blog posts, as abstract model.
    """

    class Meta:
        abstract = True


class AbstractTranslatedFieldsEntry(AbstractTranslatedFieldsEntryBase, ExcerptEntryMixin, SeoEntryMixin):
    """
    The default translated fields model for blog posts, as abstract model.
    """

    class Meta:
        abstract = True


# Make sure the 'tags' field is ignored by South
try:
    from south.modelsinspector import add_ignored_fields
except ImportError:
    pass
else:
    # South should ignore the tags field as it's a RelatedField.
    add_ignored_fields(
        ("^taggit\.managers\.TaggableManager", "^taggit_autocomplete_modified\.managers\.TaggableManagerAutocomplete")
    )
开发者ID:ZhuChaoyu,项目名称:django-fluent-blogs,代码行数:30,代码来源:base_models.py


示例8: add_ignored_fields

#############################################################

from django.utils.text import capfirst
from django.core import exceptions

#### import per eav #####
import os
project = os.path.basename(os.path.dirname(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project
import eav
from eav.forms import BaseDynamicEntityForm
from eav.models import Attribute

from south.modelsinspector import add_ignored_fields
add_ignored_fields(["^eav\.fields\.EavDatatypeField"])
add_ignored_fields(["^eav\.fields\.EavSlugField"])

#### fine import eav ####

class MultiSelectFormField(forms.MultipleChoiceField):
    widget = forms.CheckboxSelectMultiple
 
    def __init__(self, *args, **kwargs):
        self.max_choices = kwargs.pop('max_choices', 0)
        super(MultiSelectFormField, self).__init__(*args, **kwargs)
 
    def clean(self, value):
        if not value and self.required:
            raise forms.ValidationError(self.error_messages['required'])
        # if value and self.max_choices and len(value) > self.max_choices:
开发者ID:fvezzoli,项目名称:get2,代码行数:30,代码来源:models.py


示例9: add_ignored_fields

from django.db import models
from django.utils.translation import ugettext as _
from qi_toolkit.models import SimpleSearchableModel, TimestampModelMixin
from django.db.models.signals import post_save, pre_delete
from django.template.defaultfilters import slugify
from django.db import transaction

from south.modelsinspector import add_ignored_fields
add_ignored_fields(["^generic_tags\.manager.TaggableManager"])

from generic_tags import BLANK_TAGSET_NAME

from accounts.models import AccountBasedModel

class TagSet(AccountBasedModel, TimestampModelMixin):
    name = models.CharField(max_length=255, blank=True, null=True)
    order = models.IntegerField(default=0)
    slug = models.SlugField(max_length=255)

    def __unicode__(self):
        return "%s" % self.name

    def save(self, *args, **kwargs):
        if self.name == None or self.name == "":
            self.name = BLANK_TAGSET_NAME

        self.slug = slugify(self.name)
        super(TagSet,self).save(*args, **kwargs)

    class Meta(object):
        ordering = ("order",)
开发者ID:skoczen,项目名称:mycelium,代码行数:31,代码来源:models.py


示例10: add_ignored_fields

"""
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from collab.settings import INSTALLED_APPS
from django.db import models
from core.thumbs import ImageWithThumbsField
from core.taggit.managers import TaggableManager
from cache_tools.models import KeyableModel
from cache_tools.tools import expire_page
from django.core.urlresolvers import reverse
from core.helpers import format_phone_number
import datetime
from django.utils import timezone
from south.modelsinspector import add_ignored_fields

add_ignored_fields(["^core\.taggit\.managers\.TaggableManager"])


class App(models.Model):
    title = models.CharField(max_length=255)
    stub = models.CharField(max_length=32)
    description = models.CharField(max_length=255)
    path = models.CharField(max_length=32)
    icon_file = ImageWithThumbsField(upload_to='app_icons',
                                     sizes=(
                                         (300, 300), (200, 200), (100, 100)),
                                     default='app_icons/default.jpg',
                                     null=True,
                                     blank=True)

    def __unicode__(self):
开发者ID:elucify,项目名称:collab,代码行数:31,代码来源:models.py


示例11: add_ignored_fields

import django
from django.contrib.contenttypes import generic
from django.db import DEFAULT_DB_ALIAS, connection
from django.contrib.contenttypes.models import ContentType

try:
    from south.modelsinspector import add_ignored_fields
except ImportError:  # South not installed.
    pass
else:
    add_ignored_fields(["^widgy\.generic\.ProxyGenericRelation",
                        "^widgy\.generic\.ProxyGenericForeignKey",
                        "^widgy\.generic\.WidgyGenericForeignKey"])


class ProxyGenericForeignKey(generic.GenericForeignKey):
    def __init__(self, *args, **kwargs):
        kwargs['for_concrete_model'] = False
        super(ProxyGenericForeignKey, self).__init__(*args, **kwargs)


class ProxyGenericRelation(generic.GenericRelation):
    def __init__(self, *args, **kwargs):
        kwargs['for_concrete_model'] = False
        super(ProxyGenericRelation, self).__init__(*args, **kwargs)


class WidgyGenericForeignKey(ProxyGenericForeignKey):
    def __get__(self, instance, instance_type=None):
        try:
            return super(WidgyGenericForeignKey, self).__get__(instance, instance_type)
开发者ID:j00bar,项目名称:django-widgy,代码行数:31,代码来源:__init__.py


示例12: add_ignored_fields

import decimal
from datetime import datetime

from django.db import models, connection, transaction
from django.utils.translation import ugettext_lazy as _

from django_extensions.db import fields

from pergaminoweb.postgres_fts import models as fts_models

from south.modelsinspector import add_ignored_fields

# add_ignored_fields(["^pergaminoweb\.postgres_fts\.models\.VectorField",
#                     "^django_extensions\.db\.fields\.AutoSlugField",
#                     "^django_extensions\.db\.fields\.CreationDateTimeField"])
add_ignored_fields(["^pergaminoweb\.postgres_fts\.models\.VectorField"])


##### BEGIN Monkeypatch de AutoSlugField y CreationDateTimeField
# backporteado de aca: https://raw.github.com/django-extensions/django-extensions/master/django_extensions/db/fields/__init__.py
def autoslug_south_field_triple(self):
    "Returns a suitable description of this field for South."
    # We'll just introspect the _actual_ field.
    from south.modelsinspector import introspector
    field_class = "django.db.models.fields.SlugField"
    args, kwargs = introspector(self)
    # That's our definition!
    return (field_class, args, kwargs)

def creationdatetime_south_field_triple(self):
    "Returns a suitable description of this field for South."
开发者ID:garagelab,项目名称:gastopublicopergaminense,代码行数:31,代码来源:models.py


示例13: formfield

    Taggit's seems hard-coupled to taggit's own plain-text-input widget.

    """
    def formfield(self, form_class=TagField, **kwargs):
        """Swap in our custom TagField."""
        return super(BigVocabTaggableManager, self).formfield(form_class,
                                                              **kwargs)


# taggit adds a "tags" property which isn't a field, but South can't
# tell the difference. So we tell south to ignore everything in this
# module.
#
# Note: If we end up adding models to this module, then we'll need to
# rethink this.
from south.modelsinspector import add_ignored_fields
add_ignored_fields(["^kitsune\.tags\.models"])


class BigVocabTaggableMixin(models.Model):
    """Mixin for taggable models that still allows a caching manager to be the
    default manager

    Mix this in after [your caching] ModelBase.

    """
    tags = BigVocabTaggableManager()

    class Meta:
        abstract = True
开发者ID:Acidburn0zzz,项目名称:kitsune,代码行数:30,代码来源:models.py


示例14: SerializableGenericRelation

from django.contrib.contenttypes.generic import GenericRelation
from south.modelsinspector import add_ignored_fields
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured


# Trick rest_framework into serializing these relationships
class SerializableGenericRelation(GenericRelation):
    def __init__(self, *args, **kwargs):
        super(SerializableGenericRelation, self).__init__(*args, **kwargs)
        self.serialize = True

add_ignored_fields(["^wq.db.patterns.base.SerializableGenericRelation"])


# Utility for determining whether models have been swapped
class Swapper(object):
    def swappable_setting(self, app_label, model):
        if app_label == 'auth' and model == 'User':
            return 'AUTH_USER_MODEL'
        return 'WQ_%s_MODEL' % model.upper()

    def is_swapped(self, app_label, model):
        default_model = "%s.%s" % (app_label, model)
        setting = self.swappable_setting(app_label, model)
        value = getattr(settings, setting, default_model)
        if value != default_model:
            return value
        else:
            return False
开发者ID:sheppard,项目名称:wq.db,代码行数:30,代码来源:__init__.py


示例15: except

    We use it to reset the name of the socialaccount provider in
    the user's session to one that he also has.
    """
    user = socialaccount.user
    try:
        all_socialaccounts = user.socialaccount_set.all()
        next_socialaccount = all_socialaccounts[0]
        request.session['sociallogin_provider'] = next_socialaccount.provider
        request.session.modified = True
    except (ObjectDoesNotExist, IndexError):
        pass


# from https://github.com/brosner/django-timezones/pull/13
try:
    from south.modelsinspector import (add_introspection_rules,
                                       add_ignored_fields)
    add_ignored_fields(["^taggit\.managers"])
    add_introspection_rules(rules=[(
            (TimeZoneField,),   # Class(es) these apply to
            [],                 # Positional arguments (not used)
            {                   # Keyword argument
            "max_length": ["max_length", {"default": MAX_TIMEZONE_LENGTH}],
            }
            )],
        patterns=['timezones\.fields\.'])
    add_introspection_rules([], ['sumo.models.LocaleField'])
except ImportError:
    pass
开发者ID:Faldrian,项目名称:kuma,代码行数:29,代码来源:models.py


示例16: add_ignored_fields

import decimal
from datetime import datetime

from django.db import models, connection, transaction
from django.utils.translation import ugettext_lazy as _

from django_extensions.db import fields

from moronweb.postgres_fts import models as fts_models

from south.modelsinspector import add_ignored_fields

# add_ignored_fields(["^moronweb\.postgres_fts\.models\.VectorField",
#                     "^django_extensions\.db\.fields\.AutoSlugField",
#                     "^django_extensions\.db\.fields\.CreationDateTimeField"])
add_ignored_fields(["^moronweb\.postgres_fts\.models\.VectorField"])


##### BEGIN Monkeypatch de AutoSlugField y CreationDateTimeField
# backporteado de aca: https://raw.github.com/django-extensions/django-extensions/master/django_extensions/db/fields/__init__.py
def autoslug_south_field_triple(self):
    "Returns a suitable description of this field for South."
    # We'll just introspect the _actual_ field.
    from south.modelsinspector import introspector
    field_class = "django.db.models.fields.SlugField"
    args, kwargs = introspector(self)
    # That's our definition!
    return (field_class, args, kwargs)

def creationdatetime_south_field_triple(self):
    "Returns a suitable description of this field for South."
开发者ID:garagelab,项目名称:GPB,代码行数:31,代码来源:models.py


示例17: add_ignored_fields

# coding: utf-8

from django.db import models
from django.utils.translation import ugettext_lazy as _

from django_extensions.db import fields

from datetime import datetime
from gpbweb.postgres_fts import models as fts_models

from south.modelsinspector import add_ignored_fields

add_ignored_fields(["^gpbweb\.postgres_fts\.models\.VectorField",])


class ProveedorManager(models.Manager):

    def por_compras(self, **filter_args):

        filter_args['compra__fecha__gte'] = filter_args.get('compra__fecha__gte', datetime(datetime.now().year, datetime.now().month, 1))
        filter_args['compra__fecha__lte'] = filter_args.get('compra__fecha__lte', datetime.now())

        return self.select_related('compra_set') \
            .filter(**filter_args) \
            .annotate(total_compras=models.Sum('compra__importe')) \
            .order_by('-total_compras')

class Proveedor(models.Model):

    objects = ProveedorManager()
开发者ID:betorod,项目名称:GPB,代码行数:30,代码来源:models.py


示例18: __repr__

    def __repr__(self):
        return "<{0} for {1}.{2}>".format(self.__class__.__name__, self.field.model.__name__, self.field.name)


class LanguageCodeDescriptor(object):
    """
    This is the property to access the ``language_code`` in the ``TranslatableModel``.
    """
    def __get__(self, instance, instance_type=None):
        if not instance:
            raise AttributeError("language_code must be accessed via instance")

        return instance._current_language

    def __set__(self, instance, value):
        raise AttributeError("The 'language_code' attribute cannot be changed directly! Use the set_current_language() method instead.")

    def __delete__(self, instance):
        raise AttributeError("The 'language_code' attribute cannot be deleted!")


try:
    from south.modelsinspector import add_ignored_fields
except ImportError:
    pass
else:
    _name_re = "^" + __name__.replace(".", "\.")
    add_ignored_fields((
        _name_re + "\.TranslatedField",
    ))
开发者ID:pyzenberg,项目名称:django-parler,代码行数:30,代码来源:fields.py


示例19: ReverseRelatedObjectsField

from django.contrib.contenttypes.generic import GenericRelation
from genericm2m.models import RelatedObjectsDescriptor

from .models import RelatedContent


class ReverseRelatedObjectsField(RelatedObjectsDescriptor):
    def __init__(self, model=None, from_field="destination_object",
            to_field="source_object"):
        if not model:
            model = RelatedContent
        super(ReverseRelatedObjectsField, self).__init__(
                model, from_field, to_field)


class RelatedContentField(GenericRelation):
    def __init__(self, **kwargs):
        defaults = {
            "object_id_field": "source_id",
            "content_type_field": "source_type",
        }
        defaults.update(kwargs)
        super(RelatedContentField, self).__init__(RelatedContent, **defaults)

from south.modelsinspector import add_ignored_fields
add_ignored_fields(["^armstrong\.apps\.related_content\.fields\.RelatedContentField"])
开发者ID:tswicegood,项目名称:armstrong.apps.related_content,代码行数:26,代码来源:fields.py


示例20: add_ignored_fields

from django.db import models
from model_utils.models import TimeStampedModel
from model_utils.managers import QueryManager

from djorm_pgfulltext.models import SearchManager
from djorm_pgfulltext.fields import VectorField
from taggit_autosuggest_select2.managers import TaggableManager
from tinymce import models as tinymce_models
from south.modelsinspector import add_ignored_fields

add_ignored_fields(["^taggit_autosuggest_select2\.managers"])

class Link(TimeStampedModel):
    url = models.CharField("URL", max_length=1024, unique=True)
    read = models.DateTimeField("Date read", null=True, blank=True)
    summary = tinymce_models.HTMLField(blank=True)
    title = models.CharField("Title", max_length=1024, blank=True)
    search_index = VectorField()

    objects = SearchManager(
        fields = ('title', 'summary'),
        config = 'pg_catalog.english',   # this is default
        search_field = 'search_index',   # this is default
        auto_update_search_field = False # we do it using a trigger
    )

    objects_read = QueryManager(read__isnull=False).order_by('created')
    objects_unread = QueryManager(read__isnull=True).order_by('created')

    tags = TaggableManager(blank=True)
开发者ID:juliocc,项目名称:linkq,代码行数:30,代码来源:models.py



注:本文中的south.modelsinspector.add_ignored_fields函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python modelsinspector.add_introspection_rules函数代码示例发布时间:2022-05-27
下一篇:
Python models.MigrationHistory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap