Python django.db.models.options.Options() Examples
The following are 12
code examples of django.db.models.options.Options().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.db.models.options
, or try the search function
.
Example #1
Source File: base.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def copy_managers(cls, base_managers): # This is in-place sorting of an Options attribute, but that's fine. base_managers.sort() for _, mgr_name, manager in base_managers: # NOQA (redefinition of _) val = getattr(cls, mgr_name, None) if not val or val is manager: new_manager = manager._copy_to_model(cls) cls.add_to_class(mgr_name, new_manager)
Example #2
Source File: models.py From gro-api with GNU General Public License v2.0 | 5 votes |
def fields(self): return Options.fields.func(self)
Example #3
Source File: models.py From gro-api with GNU General Public License v2.0 | 5 votes |
def concrete_fields(self): return Options.concrete_fields.func(self)
Example #4
Source File: models.py From gro-api with GNU General Public License v2.0 | 5 votes |
def local_concrete_fields(self): return Options.local_concrete_fields.func(self)
Example #5
Source File: models.py From gro-api with GNU General Public License v2.0 | 5 votes |
def many_to_many(self): return Options.many_to_many.func(self)
Example #6
Source File: models.py From gro-api with GNU General Public License v2.0 | 5 votes |
def related_objects(self): return Options.related_objects.func(self)
Example #7
Source File: models.py From gro-api with GNU General Public License v2.0 | 5 votes |
def fields_map(self): return Options.fields_map.func(self)
Example #8
Source File: base.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def copy_managers(cls, base_managers): # This is in-place sorting of an Options attribute, but that's fine. base_managers.sort() for _, mgr_name, manager in base_managers: val = getattr(cls, mgr_name, None) if not val or val is manager: new_manager = manager._copy_to_model(cls) cls.add_to_class(mgr_name, new_manager)
Example #9
Source File: base.py From openhgsenti with Apache License 2.0 | 5 votes |
def copy_managers(cls, base_managers): # This is in-place sorting of an Options attribute, but that's fine. base_managers.sort() for _, mgr_name, manager in base_managers: # NOQA (redefinition of _) val = getattr(cls, mgr_name, None) if not val or val is manager: new_manager = manager._copy_to_model(cls) cls.add_to_class(mgr_name, new_manager)
Example #10
Source File: __init__.py From django-neomodel with MIT License | 5 votes |
def _meta(self): if hasattr(self.Meta, 'unique_together'): raise NotImplementedError('unique_together property not supported by neomodel') opts = Options(self.Meta, app_label=self.Meta.app_label) opts.contribute_to_class(self.__class__, self.__class__.__name__) for key, prop in self.__all_properties__: opts.add_field(DjangoField(prop, key), getattr(prop, 'private', False)) return opts
Example #11
Source File: __init__.py From django-cassandra-engine with BSD 2-Clause "Simplified" License | 4 votes |
def _give_columns_django_field_attributes(self): """ Add Django Field attributes to each cqlengine.Column instance. So that the Django Options class may interact with it as if it were a Django Field. """ methods_to_add = ( django_field_methods.value_from_object, django_field_methods.value_to_string, django_field_methods.get_attname, django_field_methods.get_cache_name, django_field_methods.pre_save, django_field_methods.get_prep_value, django_field_methods.get_choices, django_field_methods.get_choices_default, django_field_methods.save_form_data, django_field_methods.formfield, django_field_methods.get_db_prep_value, django_field_methods.get_db_prep_save, django_field_methods.db_type_suffix, django_field_methods.select_format, django_field_methods.get_internal_type, django_field_methods.get_attname_column, django_field_methods.check, django_field_methods._check_field_name, django_field_methods._check_db_index, django_field_methods.deconstruct, django_field_methods.run_validators, django_field_methods.clean, django_field_methods.get_db_converters, django_field_methods.get_prep_lookup, django_field_methods.get_db_prep_lookup, django_field_methods.get_filter_kwargs_for_object, django_field_methods.set_attributes_from_name, django_field_methods.db_parameters, django_field_methods.get_pk_value_on_save, django_field_methods.get_col, ) for name, cql_column in six.iteritems(self._defined_columns): self._set_column_django_attributes(cql_column=cql_column, name=name) for method in methods_to_add: try: method_name = method.func_name except AttributeError: # python 3 method_name = method.__name__ new_method = six.create_bound_method(method, cql_column) setattr(cql_column, method_name, new_method)
Example #12
Source File: __init__.py From django-cassandra-engine with BSD 2-Clause "Simplified" License | 4 votes |
def _add_django_meta_and_register_model(cls, klass, attrs, name): # Create the class. module = attrs.get('__module__') if not module: return klass new_class = klass attr_meta = attrs.pop('Meta', None) abstract = getattr(attr_meta, 'abstract', False) if not attr_meta: meta = getattr(new_class, 'Meta', None) else: meta = attr_meta if meta: meta.managed = False app_label = None # Look for an application configuration to attach the model to. app_config = apps.get_containing_app_config(module) if getattr(meta, 'app_label', None) is None: if app_config is None: if not abstract: raise RuntimeError( "Model class %s.%s doesn't declare an explicit " "app_label and isn't in an application in " "INSTALLED_APPS." % (module, name) ) else: app_label = app_config.label # Add _meta/Options attribute to the model new_class.add_to_class( '_meta', DjangoCassandraOptions(meta, app_label, cls=new_class)) # Add manager to the model for manager_attr in _django_manager_attr_names: new_class.add_to_class(manager_attr, new_class.objects) # Register the model new_class._meta.apps.register_model(new_class._meta.app_label, new_class) return new_class