Skip to content

Commit

Permalink
Replaced Options.object_name.lower() by Options.model_name.
Browse files Browse the repository at this point in the history
Thanks Simon for the suggestion.

Also removed inappropriate lowercasing of app labels in migrations.
Unlike model names, they are case sensitive.
aaugustin committed Dec 29, 2013
1 parent 308960b commit 20d487c
Showing 9 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{% 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 %}
{% block breadcrumbs %}
<div class="breadcrumbs">
2 changes: 1 addition & 1 deletion django/contrib/admin/templates/admin/change_form.html
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

{% 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 %}
{% block breadcrumbs %}
2 changes: 1 addition & 1 deletion django/contrib/admin/templates/admin/change_list.html
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
{% endif %}{% endif %}
{% 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 %}
{% block breadcrumbs %}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "admin/base_site.html" %}
{% 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 %}
<div class="breadcrumbs">
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "admin/base_site.html" %}
{% 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 %}
<div class="breadcrumbs">
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ <h2 id="app-{{ group.grouper }}">{{ group.grouper|capfirst }}</h2>
<table class="xfull">
{% for model in group.list %}
<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>
{% endfor %}
</table>
4 changes: 2 additions & 2 deletions django/db/migrations/autodetector.py
Original file line number Diff line number Diff line change
@@ -71,9 +71,9 @@ def _detect_changes(self):
for field in new_apps.get_model(app_label, model_name)._meta.local_fields:
if field.rel:
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:
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:
pending_add[app_label, model_name] = related_fields
else:
2 changes: 1 addition & 1 deletion django/db/migrations/state.py
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ def from_model(cls, model):
options[name] = model._meta.original_attrs[name]
# Make our record
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__
if (not hasattr(base, "_meta") or not base._meta.abstract)
)
2 changes: 1 addition & 1 deletion django/db/models/fields/related.py
Original file line number Diff line number Diff line change
@@ -1278,7 +1278,7 @@ class ForeignKey(ForeignObject):
def __init__(self, to, to_field=None, rel_class=ManyToOneRel,
db_constraint=True, **kwargs):
try:
to._meta.object_name.lower()
to._meta.model_name
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)
else:

0 comments on commit 20d487c

Please sign in to comment.