mirror of
https://github.com/graphql-python/graphene.git
synced 2025-04-09 11:54:13 +03:00
Improved app_label logic
This commit is contained in:
parent
1ec2f5a4c3
commit
e9cf8616ba
|
@ -33,7 +33,12 @@ class ObjectTypeMeta(type):
|
|||
meta = attr_meta
|
||||
base_meta = getattr(new_class, '_meta', None)
|
||||
|
||||
new_class.add_to_class('_meta', Options(meta, module))
|
||||
if '.' in module:
|
||||
app_label, _ = module.rsplit('.', 1)
|
||||
else:
|
||||
app_label = module
|
||||
|
||||
new_class.add_to_class('_meta', Options(meta, app_label))
|
||||
if base_meta and base_meta.proxy:
|
||||
new_class._meta.interface = base_meta.interface
|
||||
# Add all attributes to the class.
|
||||
|
|
|
@ -24,12 +24,12 @@ def get_registered_object_type(name, object_type=None):
|
|||
object_type_name = name
|
||||
|
||||
if '.' in name:
|
||||
app_label, object_type_name = name.split('.', 1)
|
||||
app_label, object_type_name = name.rsplit('.', 1)
|
||||
elif object_type:
|
||||
app_label = object_type._meta.app_label
|
||||
|
||||
# Filter all registered object types which have the same name
|
||||
ots = [ot for ot in registered_object_types if ot._meta.type_name == name]
|
||||
ots = [ot for ot in registered_object_types if ot._meta.type_name == object_type_name]
|
||||
# If the list have more than one object type with the name, filter by
|
||||
# the app_label
|
||||
if len(ots)>1 and app_label:
|
||||
|
|
Loading…
Reference in New Issue
Block a user