Replaced Options.object_name.lower() by Options.model_name.

Thanks Simon for the suggestion.

Also removed inappropriate lowercasing of app labels in migrations.
Unlike model names, they are case sensitive.
This commit is contained in:
Aymeric Augustin 2013-12-29 18:42:12 +01:00
parent 308960b92a
commit 20d487c27b
9 changed files with 10 additions and 10 deletions

View File

@ -6,7 +6,7 @@
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script> <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{% endblock %} {% endblock %}
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %} {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} {% block bodyclass %}{{ opts.app_label }}-{{ opts.model_name }} change-form{% endblock %}
{% if not is_popup %} {% if not is_popup %}
{% block breadcrumbs %} {% block breadcrumbs %}
<div class="breadcrumbs"> <div class="breadcrumbs">

View File

@ -10,7 +10,7 @@
{% block coltype %}colM{% endblock %} {% block coltype %}colM{% endblock %}
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} change-form{% endblock %} {% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %}
{% if not is_popup %} {% if not is_popup %}
{% block breadcrumbs %} {% block breadcrumbs %}

View File

@ -32,7 +32,7 @@
{% endif %}{% endif %} {% endif %}{% endif %}
{% endblock %} {% endblock %}
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} change-list{% endblock %} {% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %}
{% if not is_popup %} {% if not is_popup %}
{% block breadcrumbs %} {% block breadcrumbs %}

View File

@ -1,7 +1,7 @@
{% extends "admin/base_site.html" %} {% extends "admin/base_site.html" %}
{% load i18n admin_urls %} {% load i18n admin_urls %}
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} delete-confirmation{% endblock %} {% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<div class="breadcrumbs"> <div class="breadcrumbs">

View File

@ -1,7 +1,7 @@
{% extends "admin/base_site.html" %} {% extends "admin/base_site.html" %}
{% load i18n l10n admin_urls %} {% load i18n l10n admin_urls %}
{% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.object_name.lower }} delete-confirmation delete-selected-confirmation{% endblock %} {% block bodyclass %}app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation delete-selected-confirmation{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<div class="breadcrumbs"> <div class="breadcrumbs">

View File

@ -27,7 +27,7 @@
<table class="xfull"> <table class="xfull">
{% for model in group.list %} {% for model in group.list %}
<tr> <tr>
<th><a href="{% url 'django-admindocs-models-detail' app_label=model.app_label model_name=model.object_name.lower %}">{{ model.object_name }}</a></th> <th><a href="{% url 'django-admindocs-models-detail' app_label=model.app_label model_name=model.model_name %}">{{ model.object_name }}</a></th>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -71,9 +71,9 @@ class MigrationAutodetector(object):
for field in new_apps.get_model(app_label, model_name)._meta.local_fields: for field in new_apps.get_model(app_label, model_name)._meta.local_fields:
if field.rel: if field.rel:
if field.rel.to: if field.rel.to:
related_fields.append((field.name, field.rel.to._meta.app_label.lower(), field.rel.to._meta.object_name.lower())) related_fields.append((field.name, field.rel.to._meta.app_label, field.rel.to._meta.model_name))
if hasattr(field.rel, "through") and not field.rel.though._meta.auto_created: if hasattr(field.rel, "through") and not field.rel.though._meta.auto_created:
related_fields.append((field.name, field.rel.through._meta.app_label.lower(), field.rel.through._meta.object_name.lower())) related_fields.append((field.name, field.rel.through._meta.app_label, field.rel.through._meta.model_name))
if related_fields: if related_fields:
pending_add[app_label, model_name] = related_fields pending_add[app_label, model_name] = related_fields
else: else:

View File

@ -152,7 +152,7 @@ class ModelState(object):
options[name] = model._meta.original_attrs[name] options[name] = model._meta.original_attrs[name]
# Make our record # Make our record
bases = tuple( bases = tuple(
("%s.%s" % (base._meta.app_label, base._meta.object_name.lower()) if hasattr(base, "_meta") else base) ("%s.%s" % (base._meta.app_label, base._meta.model_name) if hasattr(base, "_meta") else base)
for base in model.__bases__ for base in model.__bases__
if (not hasattr(base, "_meta") or not base._meta.abstract) if (not hasattr(base, "_meta") or not base._meta.abstract)
) )

View File

@ -1278,7 +1278,7 @@ class ForeignKey(ForeignObject):
def __init__(self, to, to_field=None, rel_class=ManyToOneRel, def __init__(self, to, to_field=None, rel_class=ManyToOneRel,
db_constraint=True, **kwargs): db_constraint=True, **kwargs):
try: try:
to._meta.object_name.lower() to._meta.model_name
except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT
assert isinstance(to, six.string_types), "%s(%r) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT) assert isinstance(to, six.string_types), "%s(%r) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT)
else: else: