本文整理汇总了Python中south.modelsinspector.add_ignored_fields函数的典型用法代码示例。如果您正苦于以下问题:Python add_ignored_fields函数的具体用法?Python add_ignored_fields怎么用?Python add_ignored_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_ignored_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"])
示例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",
))
示例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
示例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
示例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
示例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']
示例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")
)
示例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:
示例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",)
示例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):
示例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)
示例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."
示例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
示例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
示例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