Skip to content

Commit

Permalink
Renamed registered_model to has_model.
Browse files Browse the repository at this point in the history
This avoids possible confusion with register_model.

Thanks Marc Tamlyn for the suggestion.
  • Loading branch information
aaugustin committed Dec 22, 2013
1 parent 65cd74b commit 70c9654
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions django/core/apps/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ def register_model(self, app_label, model):
models[model_name] = model
self._get_models_cache.clear()

def registered_model(self, app_label, model_name):
def has_model(self, app_label, model_name):
"""
Test if a model is registered and return the model class or None.
Returns the model class if one is registered and None otherwise.
It's safe to call this method at import time, even while the app cache
is being populated.
is being populated. It returns None for models that aren't loaded yet.
"""
return self.all_models[app_label].get(model_name.lower())

Expand Down
4 changes: 2 additions & 2 deletions django/db/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def __new__(cls, name, bases, attrs):
new_class._base_manager = new_class._base_manager._copy_to_model(new_class)

# Bail out early if we have already created this class.
m = new_class._meta.app_cache.registered_model(new_class._meta.app_label, name)
m = new_class._meta.app_cache.has_model(new_class._meta.app_label, name)
if m is not None:
return m

Expand Down Expand Up @@ -278,7 +278,7 @@ def __new__(cls, name, bases, attrs):
# the first time this model tries to register with the framework. There
# should only be one class for each model, so we always return the
# registered version.
return new_class._meta.app_cache.registered_model(new_class._meta.app_label, name)
return new_class._meta.app_cache.has_model(new_class._meta.app_label, name)

def copy_managers(cls, base_managers):
# This is in-place sorting of an Options attribute, but that's fine.
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/fields/related.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MyModel(Model):
# string right away. If get_model returns None, it means that the related
# model isn't loaded yet, so we need to pend the relation until the class
# is prepared.
model = cls._meta.app_cache.registered_model(app_label, model_name)
model = cls._meta.app_cache.has_model(app_label, model_name)
if model:
operation(field, model, cls)
else:
Expand Down

0 comments on commit 70c9654

Please sign in to comment.