本文整理汇总了Python中south.modelsinspector.add_introspection_rules函数的典型用法代码示例。如果您正苦于以下问题:Python add_introspection_rules函数的具体用法?Python add_introspection_rules怎么用?Python add_introspection_rules使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_introspection_rules函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
kwargs.setdefault('max_length', 7)
kwargs.setdefault('choices', [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES])
add_introspection_rules([], ["^languages\.fields\.LanguageField"])
super(LanguageField, self).__init__(*args, **kwargs)
示例2: try_initialize_south
def try_initialize_south():
try:
import south
except ImportError:
# No south in pypath
return
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^current_user\.models\.CurrentUserField"])
示例3: register_south_field
def register_south_field(field_class):
# make the fields work in South
from south.modelsinspector import add_introspection_rules
module = field_class.__module__
regex = r'^%s\.%s' % (re.escape(module), field_class.__name__)
add_introspection_rules([], [regex])
return field_class
示例4: add_to_introspection_rule
def add_to_introspection_rule(self):
try:
from south.modelsinspector import add_introspection_rules
except ImportError:
pass
else:
add_introspection_rules(
[([JsonDataField], [], {}), ],
["^gtoolkit\.db\.fields\.JsonDataField"])
示例5: add_south_rules
def add_south_rules():
from south.modelsinspector import add_introspection_rules
add_introspection_rules([
(
(VersionField,),
[],
{'partial': ('partial', {'default': False})},
),
], ["semantic_version\.django_fields"])
示例6: add_south_rules
def add_south_rules():
from south.modelsinspector import add_introspection_rules
add_introspection_rules([
(
(VersionField,),
[],
{},
),
], ["whatsnew\.fields"])
示例7: ready
def ready(self):
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^markupfield\.fields\.MarkupField"])
# ping_details = {'blogango_details': pingback_blog_handler}
from pingback import register_pingback, ping_func
from . import pingback_blog_handler
from django_xmlrpc import xmlrpcdispatcher
register_pingback('blogango.views.details', pingback_blog_handler)
xmlrpcdispatcher.register_function(ping_func, 'pingback.ping')
示例8: load_object_field
def load_object_field():
try:
from south.modelsinspector import add_introspection_rules
except ImportError:
pass
else:
add_introspection_rules(
[([ObjectField], [], {}),],
["^gtoolkit\.db\.fields\.ObjectField"])
add_introspection_rules(
[([UniqueIDField], [], {}),],
["^gtoolkit\.db\.fields\.UniqueIDField"])
示例9: add_south_introspector_rules
def add_south_introspector_rules():
from south.modelsinspector import add_introspection_rules
rules = [
(
(StateFlowField, ),
[],
{
"flow": ["flow_path", {}],
}
),
]
add_introspection_rules(rules, ["^stateflow\.statefields"])
示例10: try_initialize_south
def try_initialize_south():
try:
import south
except ImportError:
# No south in pypath
return
from south.modelsinspector import add_introspection_rules
from .fields import DictionaryField
rules = [(
(DictionaryField,),
[],
{
'type': ['type', {}],
# 'render_pattern': ['render_pattern', {'default', None}],
},
)]
add_introspection_rules(rules, ["^django_dict\.fields\.DictionaryField"])
示例11: super
self._dbtype = dbtype
kwargs.setdefault('blank', True)
kwargs.setdefault('null', True)
kwargs.setdefault('default', None)
super(GeometricField, self).__init__(*args, **kwargs)
def db_type(self, connection):
return self._dbtype.db_type(connection)
def get_db_prep_value(self, value, connection, prepared=False):
value = value if prepared else self.get_prep_value(value)
return value
def to_python(self, value):
return value
try:
from south.modelsinspector import add_introspection_rules
from .objects import Point
add_introspection_rules([
(
[GeometricField], # class
[], # positional params
{'dbtype': ["_dbtype", {"default": Point}]}, # kwargs
)
], ['django_orm\.postgresql\.geometric\.fields\.GeometricField'])
except ImportError:
pass
示例12: __init__
"""
The image field based on django-filebrowser, SORL thumbnail or any other image library.
It's a drop-in replacement for the django :class:`~django.db.models.ImageField`
When *django-filebrowser* is not installed, it will display the
standard :class:`~django.db.models.ImageField` with a preview attached to it.
"""
def __init__(self, *args, **kwargs):
# django-filebrowser has no concept of a 'width_field',
# only Django's ImageField has this feature.
if 'width_field' in kwargs:
raise NotImplementedError("Unable to use 'width_field' in AnyImageField, not all backends support this feature.")
if 'height_field' in kwargs:
raise NotImplementedError("Unable to use 'height_field' in AnyImageField, not all backends support this feature.")
super(AnyImageField, self).__init__(*args, **kwargs)
# Tell South how to create custom fields
try:
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], [
"^any_imagefield\.models\.fields\.AnyFileField",
"^any_imagefield\.models\.fields\.AnyImageField",
"^any_imagefield\.models\.fields\.backends\.([^.]+)\.AnyFileField",
"^any_imagefield\.models\.fields\.backends\.([^.]+)\.AnyImageField",
])
except ImportError:
pass
示例13: AddressPickerField
from django.db import models
from django import forms
from .widjets import AddressPickerWidget
class AddressPickerField(models.CharField):
def __init__(self, *args, **kwargs):
super(AddressPickerField, self).__init__(*args, **kwargs)
def formfield(self, **kwargs):
defaults = {
'form_class': AddressPickerFormField,
}
defaults.update(kwargs)
return super(AddressPickerField, self).formfield(**defaults)
class AddressPickerFormField(forms.fields.CharField):
def __init__(self, *args, **kwargs):
kwargs.update({'widget': AddressPickerWidget()})
super(AddressPickerFormField, self).__init__(*args, **kwargs)
try:
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^addresspicker\.fields\.AddressPickerField"])
except ImportError:
pass
示例14: add_introspection_rules
from django.db.models import FileField
from django import forms
from django.utils.translation import ugettext as _
import pyfits
from specreduce.specreduce import OneDimensionalSpectrumValidator
from specreduce.specreduce import ValidationError
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^spectra\.extra\.OneDimensionalSpectrumFileField"])
class OneDimensionalSpectrumFileField(FileField):
def clean(self, *args, **kwargs):
data = super(OneDimensionalSpectrumFileField, self).clean(*args, **kwargs)
# This will raise IOError if there is a parse failure
try:
hdulist = pyfits.open(data.file)
except IOError as e:
raise forms.ValidationError(_('Unable to parse FITS file: %s' % e))
try:
OneDimensionalSpectrumValidator(hdulist).validate()
except ValidationError as e:
raise forms.ValidationError(_('FITS validation failed: %s' % e))
return data
示例15: callable
if self.has_default():
if callable(self.default):
return self.default()
return copy.deepcopy(self.default)
# If the field doesn't have a default, then we punt to models.Field.
return super(JSONFieldBase, self).get_default()
class JSONField(JSONFieldBase, models.TextField):
"""JSONField is a generic textfield that serializes/deserializes JSON objects"""
form_class = JSONFormField
def dumps_for_display(self, value):
kwargs = {"indent": 2}
kwargs.update(self.dump_kwargs)
return json.dumps(value, ensure_ascii=False, **kwargs)
class JSONCharField(JSONFieldBase, models.CharField):
"""JSONCharField is a generic textfield that serializes/deserializes JSON objects,
stored in the database like a CharField, which enables it to be used
e.g. in unique keys"""
form_class = JSONCharFormField
try:
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^jsonfield\.fields\.(JSONField|JSONCharField)"])
except ImportError:
pass