Code

Ticket #19689: 0001-Fixed-19689-Deprecated-model-meta-s-module_name-in-f.patch

File 0001-Fixed-19689-Deprecated-model-meta-s-module_name-in-f.patch, 43.0 KB (added by charettes, 15 months ago)

with doc

  • django/contrib/admin/actions.py

    From f5e7de26d250d59386a0f75f9dfadd7cdf44dd89 Mon Sep 17 00:00:00 2001
    From: Simon Charette <charette.s@gmail.com>
    Date: Mon, 4 Feb 2013 19:42:40 -0500
    Subject: [PATCH] Fixed #19689 -- Deprecated model meta's module_name in favor
     of model_name.
    
    ---
     django/contrib/admin/actions.py                    |    2 +-
     django/contrib/admin/options.py                    |   24 ++++++++--------
     django/contrib/admin/sites.py                      |    6 ++--
     .../templates/admin/auth/user/change_password.html |    2 +-
     .../contrib/admin/templates/admin/change_form.html |    2 +-
     django/contrib/admin/templatetags/admin_urls.py    |    3 +-
     django/contrib/admin/util.py                       |    2 +-
     django/contrib/admin/views/main.py                 |    2 +-
     django/contrib/admin/widgets.py                    |    4 +--
     django/contrib/admindocs/views.py                  |   12 ++++----
     django/contrib/auth/context_processors.py          |   16 +++++------
     django/contrib/auth/management/__init__.py         |    2 +-
     django/contrib/comments/moderation.py              |    4 +--
     django/contrib/comments/views/comments.py          |    4 +--
     django/contrib/contenttypes/generic.py             |    4 +--
     django/contrib/contenttypes/management.py          |    2 +-
     django/contrib/contenttypes/models.py              |   10 +++----
     django/contrib/gis/sitemaps/kml.py                 |    2 +-
     django/core/cache/backends/db.py                   |    2 +-
     django/core/management/sql.py                      |    4 +--
     django/core/serializers/python.py                  |    2 +-
     django/core/xheaders.py                            |    2 +-
     django/db/models/base.py                           |    4 +--
     django/db/models/fields/related.py                 |    8 +++---
     django/db/models/loading.py                        |    2 +-
     django/db/models/options.py                        |   29 ++++++++++++++------
     django/db/models/related.py                        |   10 +++----
     django/views/generic/detail.py                     |    6 ++--
     django/views/generic/list.py                       |    4 +--
     docs/internals/deprecation.txt                     |    4 +++
     docs/releases/1.6.txt                              |    6 ++++
     tests/regressiontests/admin_custom_urls/models.py  |    2 +-
     32 files changed, 104 insertions(+), 84 deletions(-)
    
    diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py
    index 2011017..d11ba3d 100644
    a b def delete_selected(modeladmin, request, queryset): 
    7575 
    7676    # Display the confirmation page 
    7777    return TemplateResponse(request, modeladmin.delete_selected_confirmation_template or [ 
    78         "admin/%s/%s/delete_selected_confirmation.html" % (app_label, opts.object_name.lower()), 
     78        "admin/%s/%s/delete_selected_confirmation.html" % (app_label, opts.model_name), 
    7979        "admin/%s/delete_selected_confirmation.html" % app_label, 
    8080        "admin/delete_selected_confirmation.html" 
    8181    ], context, current_app=modeladmin.admin_site.name) 
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 8e0aacc..8de3112 100644
    a b class ModelAdmin(BaseModelAdmin): 
    371371                return self.admin_site.admin_view(view)(*args, **kwargs) 
    372372            return update_wrapper(wrapper, view) 
    373373 
    374         info = self.model._meta.app_label, self.model._meta.module_name 
     374        info = self.model._meta.app_label, self.model._meta.model_name 
    375375 
    376376        urlpatterns = patterns('', 
    377377            url(r'^$', 
    class ModelAdmin(BaseModelAdmin): 
    783783            form_template = self.change_form_template 
    784784 
    785785        return TemplateResponse(request, form_template or [ 
    786             "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()), 
     786            "admin/%s/%s/change_form.html" % (app_label, opts.model_name), 
    787787            "admin/%s/change_form.html" % app_label, 
    788788            "admin/change_form.html" 
    789789        ], context, current_app=self.admin_site.name) 
    class ModelAdmin(BaseModelAdmin): 
    803803            self.message_user(request, msg) 
    804804            if post_url_continue is None: 
    805805                post_url_continue = reverse('admin:%s_%s_change' % 
    806                                             (opts.app_label, opts.module_name), 
     806                                            (opts.app_label, opts.model_name), 
    807807                                            args=(pk_value,), 
    808808                                            current_app=self.admin_site.name) 
    809809            if "_popup" in request.POST: 
    class ModelAdmin(BaseModelAdmin): 
    845845            msg = _('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % msg_dict 
    846846            self.message_user(request, msg) 
    847847            return HttpResponseRedirect(reverse('admin:%s_%s_change' % 
    848                                         (opts.app_label, opts.module_name), 
     848                                        (opts.app_label, opts.model_name), 
    849849                                        args=(pk_value,), 
    850850                                        current_app=self.admin_site.name)) 
    851851        elif "_addanother" in request.POST: 
    852852            msg = _('The %(name)s "%(obj)s" was changed successfully. You may add another %(name)s below.') % msg_dict 
    853853            self.message_user(request, msg) 
    854854            return HttpResponseRedirect(reverse('admin:%s_%s_add' % 
    855                                         (opts.app_label, opts.module_name), 
     855                                        (opts.app_label, opts.model_name), 
    856856                                        current_app=self.admin_site.name)) 
    857857        else: 
    858858            msg = _('The %(name)s "%(obj)s" was changed successfully.') % msg_dict 
    class ModelAdmin(BaseModelAdmin): 
    867867        opts = self.model._meta 
    868868        if self.has_change_permission(request, None): 
    869869            post_url = reverse('admin:%s_%s_changelist' % 
    870                                (opts.app_label, opts.module_name), 
     870                               (opts.app_label, opts.model_name), 
    871871                               current_app=self.admin_site.name) 
    872872        else: 
    873873            post_url = reverse('admin:index', 
    class ModelAdmin(BaseModelAdmin): 
    882882        opts = self.model._meta 
    883883        if self.has_change_permission(request, None): 
    884884            post_url = reverse('admin:%s_%s_changelist' % 
    885                                (opts.app_label, opts.module_name), 
     885                               (opts.app_label, opts.model_name), 
    886886                               current_app=self.admin_site.name) 
    887887        else: 
    888888            post_url = reverse('admin:index', 
    class ModelAdmin(BaseModelAdmin): 
    10601060 
    10611061        if request.method == 'POST' and "_saveasnew" in request.POST: 
    10621062            return self.add_view(request, form_url=reverse('admin:%s_%s_add' % 
    1063                                     (opts.app_label, opts.module_name), 
     1063                                    (opts.app_label, opts.model_name), 
    10641064                                    current_app=self.admin_site.name)) 
    10651065 
    10661066        ModelForm = self.get_form(request, obj) 
    class ModelAdmin(BaseModelAdmin): 
    12831283        context.update(extra_context or {}) 
    12841284 
    12851285        return TemplateResponse(request, self.change_list_template or [ 
    1286             'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), 
     1286            'admin/%s/%s/change_list.html' % (app_label, opts.model_name), 
    12871287            'admin/%s/change_list.html' % app_label, 
    12881288            'admin/change_list.html' 
    12891289        ], context, current_app=self.admin_site.name) 
    class ModelAdmin(BaseModelAdmin): 
    13231323                return HttpResponseRedirect(reverse('admin:index', 
    13241324                                                    current_app=self.admin_site.name)) 
    13251325            return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % 
    1326                                         (opts.app_label, opts.module_name), 
     1326                                        (opts.app_label, opts.model_name), 
    13271327                                        current_app=self.admin_site.name)) 
    13281328 
    13291329        object_name = force_text(opts.verbose_name) 
    class ModelAdmin(BaseModelAdmin): 
    13461346        context.update(extra_context or {}) 
    13471347 
    13481348        return TemplateResponse(request, self.delete_confirmation_template or [ 
    1349             "admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower()), 
     1349            "admin/%s/%s/delete_confirmation.html" % (app_label, opts.model_name), 
    13501350            "admin/%s/delete_confirmation.html" % app_label, 
    13511351            "admin/delete_confirmation.html" 
    13521352        ], context, current_app=self.admin_site.name) 
    class ModelAdmin(BaseModelAdmin): 
    13731373        } 
    13741374        context.update(extra_context or {}) 
    13751375        return TemplateResponse(request, self.object_history_template or [ 
    1376             "admin/%s/%s/object_history.html" % (app_label, opts.object_name.lower()), 
     1376            "admin/%s/%s/object_history.html" % (app_label, opts.model_name), 
    13771377            "admin/%s/object_history.html" % app_label, 
    13781378            "admin/object_history.html" 
    13791379        ], context, current_app=self.admin_site.name) 
  • django/contrib/admin/sites.py

    diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
    index 1854170..07d1ec7 100644
    a b class AdminSite(object): 
    247247        # Add in each model's views. 
    248248        for model, model_admin in six.iteritems(self._registry): 
    249249            urlpatterns += patterns('', 
    250                 url(r'^%s/%s/' % (model._meta.app_label, model._meta.module_name), 
     250                url(r'^%s/%s/' % (model._meta.app_label, model._meta.model_name), 
    251251                    include(model_admin.urls)) 
    252252            ) 
    253253        return urlpatterns 
    class AdminSite(object): 
    351351                # Check whether user has any perm for this module. 
    352352                # If so, add the module to the model_list. 
    353353                if True in perms.values(): 
    354                     info = (app_label, model._meta.module_name) 
     354                    info = (app_label, model._meta.model_name) 
    355355                    model_dict = { 
    356356                        'name': capfirst(model._meta.verbose_name_plural), 
    357357                        'object_name': model._meta.object_name, 
    class AdminSite(object): 
    407407                    # Check whether user has any perm for this module. 
    408408                    # If so, add the module to the model_list. 
    409409                    if True in perms.values(): 
    410                         info = (app_label, model._meta.module_name) 
     410                        info = (app_label, model._meta.model_name) 
    411411                        model_dict = { 
    412412                            'name': capfirst(model._meta.verbose_name_plural), 
    413413                            'object_name': model._meta.object_name, 
  • django/contrib/admin/templates/admin/auth/user/change_password.html

    diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html
    index 83a9c48..9d1b917 100644
    a b  
    1919{% endblock %} 
    2020{% endif %} 
    2121{% block content %}<div id="content-main"> 
    22 <form action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %} 
     22<form action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %} 
    2323<div> 
    2424{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %} 
    2525{% if form.errors %} 
  • django/contrib/admin/templates/admin/change_form.html

    diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html
    index 4884696..daf3775 100644
    a b  
    3535  </ul> 
    3636{% endif %}{% endif %} 
    3737{% endblock %} 
    38 <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %} 
     38<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %} 
    3939<div> 
    4040{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %} 
    4141{% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %} 
  • django/contrib/admin/templatetags/admin_urls.py

    diff --git a/django/contrib/admin/templatetags/admin_urls.py b/django/contrib/admin/templatetags/admin_urls.py
    index 90e81b0..bca95d9 100644
    a b  
    1 from django.core.urlresolvers import reverse 
    21from django import template 
    32from django.contrib.admin.util import quote 
    43 
    register = template.Library() 
    65 
    76@register.filter 
    87def admin_urlname(value, arg): 
    9     return 'admin:%s_%s_%s' % (value.app_label, value.module_name, arg) 
     8    return 'admin:%s_%s_%s' % (value.app_label, value.model_name, arg) 
    109 
    1110 
    1211@register.filter 
  • django/contrib/admin/util.py

    diff --git a/django/contrib/admin/util.py b/django/contrib/admin/util.py
    index 07013d1..133a8ad 100644
    a b def get_deleted_objects(objs, opts, user, admin_site, using): 
    116116            admin_url = reverse('%s:%s_%s_change' 
    117117                                % (admin_site.name, 
    118118                                   opts.app_label, 
    119                                    opts.object_name.lower()), 
     119                                   opts.model_name), 
    120120                                None, (quote(obj._get_pk_val()),)) 
    121121            p = '%s.%s' % (opts.app_label, 
    122122                           opts.get_delete_permission()) 
  • django/contrib/admin/views/main.py

    diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
    index be7067f..4b296b3 100644
    a b class ChangeList(object): 
    379379    def url_for_result(self, result): 
    380380        pk = getattr(result, self.pk_attname) 
    381381        return reverse('admin:%s_%s_change' % (self.opts.app_label, 
    382                                                self.opts.module_name), 
     382                                               self.opts.model_name), 
    383383                       args=(quote(pk),), 
    384384                       current_app=self.model_admin.admin_site.name) 
  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    index a388774..4b79401 100644
    a b class ForeignKeyRawIdWidget(forms.TextInput): 
    147147            # The related object is registered with the same AdminSite 
    148148            related_url = reverse('admin:%s_%s_changelist' % 
    149149                                    (rel_to._meta.app_label, 
    150                                     rel_to._meta.module_name), 
     150                                    rel_to._meta.model_name), 
    151151                                    current_app=self.admin_site.name) 
    152152 
    153153            params = self.url_parameters() 
    class RelatedFieldWidgetWrapper(forms.Widget): 
    247247 
    248248    def render(self, name, value, *args, **kwargs): 
    249249        rel_to = self.rel.to 
    250         info = (rel_to._meta.app_label, rel_to._meta.object_name.lower()) 
     250        info = (rel_to._meta.app_label, rel_to._meta.model_name) 
    251251        self.widget.choices = self.choices 
    252252        output = [self.widget.render(name, value, *args, **kwargs)] 
    253253        if self.can_add_related: 
  • django/contrib/admindocs/views.py

    diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py
    index cb0c116..ef2790f 100644
    a b def model_detail(request, app_label, model_name): 
    189189        raise Http404(_("App %r not found") % app_label) 
    190190    model = None 
    191191    for m in models.get_models(app_mod): 
    192         if m._meta.object_name.lower() == model_name: 
     192        if m._meta.model_name == model_name: 
    193193            model = m 
    194194            break 
    195195    if model is None: 
    def model_detail(request, app_label, model_name): 
    224224        fields.append({ 
    225225            'name': "%s.all" % field.name, 
    226226            "data_type": 'List', 
    227             'verbose': utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.module_name), 
     227            'verbose': utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.model_name), 
    228228        }) 
    229229        fields.append({ 
    230230            'name'      : "%s.count" % field.name, 
    231231            'data_type' : 'Integer', 
    232             'verbose'   : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.module_name), 
     232            'verbose'   : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.model_name), 
    233233        }) 
    234234 
    235235    # Gather model methods. 
    def model_detail(request, app_label, model_name): 
    243243                continue 
    244244            verbose = func.__doc__ 
    245245            if verbose: 
    246                 verbose = utils.parse_rst(utils.trim_docstring(verbose), 'model', _('model:') + opts.module_name) 
     246                verbose = utils.parse_rst(utils.trim_docstring(verbose), 'model', _('model:') + opts.model_name) 
    247247            fields.append({ 
    248248                'name': func_name, 
    249249                'data_type': get_return_data_type(func_name), 
    def model_detail(request, app_label, model_name): 
    257257        fields.append({ 
    258258            'name'      : "%s.all" % accessor, 
    259259            'data_type' : 'List', 
    260             'verbose'   : utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.module_name), 
     260            'verbose'   : utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.model_name), 
    261261        }) 
    262262        fields.append({ 
    263263            'name'      : "%s.count" % accessor, 
    264264            'data_type' : 'Integer', 
    265             'verbose'   : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.module_name), 
     265            'verbose'   : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.model_name), 
    266266        }) 
    267267    return render_to_response('admin_doc/model_detail.html', { 
    268268        'root_path': urlresolvers.reverse('admin:index'), 
  • django/contrib/auth/context_processors.py

    diff --git a/django/contrib/auth/context_processors.py b/django/contrib/auth/context_processors.py
    index 3d17fe2..b8ead73 100644
    a b  
    22# the template system can understand. 
    33 
    44class PermLookupDict(object): 
    5     def __init__(self, user, module_name): 
    6         self.user, self.module_name = user, module_name 
     5    def __init__(self, user, app_label): 
     6        self.user, self.app_label = user, app_label 
    77 
    88    def __repr__(self): 
    99        return str(self.user.get_all_permissions()) 
    1010 
    1111    def __getitem__(self, perm_name): 
    12         return self.user.has_perm("%s.%s" % (self.module_name, perm_name)) 
     12        return self.user.has_perm("%s.%s" % (self.app_label, perm_name)) 
    1313 
    1414    def __iter__(self): 
    1515        # To fix 'item in perms.someapp' and __getitem__ iteraction we need to 
    class PermLookupDict(object): 
    1717        raise TypeError("PermLookupDict is not iterable.") 
    1818 
    1919    def __bool__(self): 
    20         return self.user.has_module_perms(self.module_name) 
     20        return self.user.has_module_perms(self.app_label) 
    2121 
    2222    def __nonzero__(self):      # Python 2 compatibility 
    2323        return type(self).__bool__(self) 
    class PermWrapper(object): 
    2727    def __init__(self, user): 
    2828        self.user = user 
    2929 
    30     def __getitem__(self, module_name): 
    31         return PermLookupDict(self.user, module_name) 
     30    def __getitem__(self, app_label): 
     31        return PermLookupDict(self.user, app_label) 
    3232 
    3333    def __iter__(self): 
    3434        # I am large, I contain multitudes. 
    class PermWrapper(object): 
    4141        if '.' not in perm_name: 
    4242            # The name refers to module. 
    4343            return bool(self[perm_name]) 
    44         module_name, perm_name = perm_name.split('.', 1) 
    45         return self[module_name][perm_name] 
     44        app_label, perm_name = perm_name.split('.', 1) 
     45        return self[app_label][perm_name] 
    4646 
    4747 
    4848def auth(request): 
  • django/contrib/auth/management/__init__.py

    diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
    index a77bba0..475dd25 100644
    a b from django.utils.six.moves import input 
    1717 
    1818 
    1919def _get_permission_codename(action, opts): 
    20     return '%s_%s' % (action, opts.object_name.lower()) 
     20    return '%s_%s' % (action, opts.model_name) 
    2121 
    2222 
    2323def _get_all_permissions(opts, ctype): 
  • django/contrib/comments/moderation.py

    diff --git a/django/contrib/comments/moderation.py b/django/contrib/comments/moderation.py
    index 6c56d7a..6648aeb 100644
    a b class Moderator(object): 
    302302            model_or_iterable = [model_or_iterable] 
    303303        for model in model_or_iterable: 
    304304            if model in self._registry: 
    305                 raise AlreadyModerated("The model '%s' is already being moderated" % model._meta.module_name) 
     305                raise AlreadyModerated("The model '%s' is already being moderated" % model._meta.model_name) 
    306306            self._registry[model] = moderation_class(model) 
    307307 
    308308    def unregister(self, model_or_iterable): 
    class Moderator(object): 
    318318            model_or_iterable = [model_or_iterable] 
    319319        for model in model_or_iterable: 
    320320            if model not in self._registry: 
    321                 raise NotModerated("The model '%s' is not currently being moderated" % model._meta.module_name) 
     321                raise NotModerated("The model '%s' is not currently being moderated" % model._meta.model_name) 
    322322            del self._registry[model] 
    323323 
    324324    def pre_save_moderation(self, sender, comment, request, **kwargs): 
  • django/contrib/comments/views/comments.py

    diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py
    index 7c02b21..befd326 100644
    a b def post_comment(request, next=None, using=None): 
    8686            # These first two exist for purely historical reasons. 
    8787            # Django v1.0 and v1.1 allowed the underscore format for 
    8888            # preview templates, so we have to preserve that format. 
    89             "comments/%s_%s_preview.html" % (model._meta.app_label, model._meta.module_name), 
     89            "comments/%s_%s_preview.html" % (model._meta.app_label, model._meta.model_name), 
    9090            "comments/%s_preview.html" % model._meta.app_label, 
    9191            # Now the usual directory based template hierarchy. 
    92             "comments/%s/%s/preview.html" % (model._meta.app_label, model._meta.module_name), 
     92            "comments/%s/%s/preview.html" % (model._meta.app_label, model._meta.model_name), 
    9393            "comments/%s/preview.html" % model._meta.app_label, 
    9494            "comments/preview.html", 
    9595        ] 
  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    index cda4d46..d849d16 100644
    a b class BaseGenericInlineFormSet(BaseModelFormSet): 
    389389        opts = self.model._meta 
    390390        self.instance = instance 
    391391        self.rel_name = '-'.join(( 
    392             opts.app_label, opts.object_name.lower(), 
     392            opts.app_label, opts.model_name, 
    393393            self.ct_field.name, self.ct_fk_field.name, 
    394394        )) 
    395395        if self.instance is None or self.instance.pk is None: 
    class BaseGenericInlineFormSet(BaseModelFormSet): 
    409409    @classmethod 
    410410    def get_default_prefix(cls): 
    411411        opts = cls.model._meta 
    412         return '-'.join((opts.app_label, opts.object_name.lower(), 
     412        return '-'.join((opts.app_label, opts.model_name, 
    413413                        cls.ct_field.name, cls.ct_fk_field.name, 
    414414        )) 
    415415 
  • django/contrib/contenttypes/management.py

    diff --git a/django/contrib/contenttypes/management.py b/django/contrib/contenttypes/management.py
    index 8329ab6..ddd7654 100644
    a b def update_contenttypes(app, created_models, verbosity=2, db=DEFAULT_DB_ALIAS, * 
    2121    # They all have the same app_label, get the first one. 
    2222    app_label = app_models[0]._meta.app_label 
    2323    app_models = dict( 
    24         (model._meta.object_name.lower(), model) 
     24        (model._meta.model_name, model) 
    2525        for model in app_models 
    2626    ) 
    2727 
  • django/contrib/contenttypes/models.py

    diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py
    index b658655..f0bd109 100644
    a b class ContentTypeManager(models.Manager): 
    2525        return model._meta 
    2626 
    2727    def _get_from_cache(self, opts): 
    28         key = (opts.app_label, opts.object_name.lower()) 
     28        key = (opts.app_label, opts.model_name) 
    2929        return self.__class__._cache[self.db][key] 
    3030 
    3131    def get_for_model(self, model, for_concrete_model=True): 
    class ContentTypeManager(models.Manager): 
    4343            # django.utils.functional.__proxy__ object. 
    4444            ct, created = self.get_or_create( 
    4545                app_label = opts.app_label, 
    46                 model = opts.object_name.lower(), 
     46                model = opts.model_name, 
    4747                defaults = {'name': smart_text(opts.verbose_name_raw)}, 
    4848            ) 
    4949            self._add_to_cache(self.db, ct) 
    class ContentTypeManager(models.Manager): 
    6767                ct = self._get_from_cache(opts) 
    6868            except KeyError: 
    6969                needed_app_labels.add(opts.app_label) 
    70                 needed_models.add(opts.object_name.lower()) 
     70                needed_models.add(opts.model_name) 
    7171                needed_opts.add(opts) 
    7272            else: 
    7373                results[model] = ct 
    class ContentTypeManager(models.Manager): 
    8686            # These weren't in the cache, or the DB, create them. 
    8787            ct = self.create( 
    8888                app_label=opts.app_label, 
    89                 model=opts.object_name.lower(), 
     89                model=opts.model_name, 
    9090                name=smart_text(opts.verbose_name_raw), 
    9191            ) 
    9292            self._add_to_cache(self.db, ct) 
    class ContentTypeManager(models.Manager): 
    119119    def _add_to_cache(self, using, ct): 
    120120        """Insert a ContentType into the cache.""" 
    121121        model = ct.model_class() 
    122         key = (model._meta.app_label, model._meta.object_name.lower()) 
     122        key = (model._meta.app_label, model._meta.model_name) 
    123123        self.__class__._cache.setdefault(using, {})[key] = ct 
    124124        self.__class__._cache.setdefault(using, {})[ct.id] = ct 
    125125 
  • django/contrib/gis/sitemaps/kml.py

    diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py
    index db30606..837fe62 100644
    a b class KMLSitemap(Sitemap): 
    3030                for field in source._meta.fields: 
    3131                    if isinstance(field, GeometryField): 
    3232                        kml_sources.append((source._meta.app_label, 
    33                                             source._meta.module_name, 
     33                                            source._meta.model_name, 
    3434                                            field.name)) 
    3535            elif isinstance(source, (list, tuple)): 
    3636                if len(source) != 3:  
  • django/core/cache/backends/db.py

    diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
    index c93bc90..5c9ea3e 100644
    a b class Options(object): 
    2323    def __init__(self, table): 
    2424        self.db_table = table 
    2525        self.app_label = 'django_cache' 
    26         self.module_name = 'cacheentry' 
     26        self.model_name = 'cacheentry' 
    2727        self.verbose_name = 'cache entry' 
    2828        self.verbose_name_plural = 'cache entries' 
    2929        self.object_name =  'CacheEntry' 
  • django/core/management/sql.py

    diff --git a/django/core/management/sql.py b/django/core/management/sql.py
    index e46f4ae..66df43e 100644
    a b def custom_sql_for_model(model, style, connection): 
    173173 
    174174    # Find custom SQL, if it's available. 
    175175    backend_name = connection.settings_dict['ENGINE'].split('.')[-1] 
    176     sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), backend_name)), 
    177                  os.path.join(app_dir, "%s.sql" % opts.object_name.lower())] 
     176    sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.model_name, backend_name)), 
     177                 os.path.join(app_dir, "%s.sql" % opts.model_name)] 
    178178    for sql_file in sql_files: 
    179179        if os.path.exists(sql_file): 
    180180            with codecs.open(sql_file, 'U', encoding=settings.FILE_CHARSET) as fp: 
  • django/core/serializers/python.py

    diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py
    index 37fa906..5e07e2a 100644
    a b def Deserializer(object_list, **options): 
    143143 
    144144def _get_model(model_identifier): 
    145145    """ 
    146     Helper to look up a model from an "app_label.module_name" string. 
     146    Helper to look up a model from an "app_label.model_name" string. 
    147147    """ 
    148148    try: 
    149149        Model = models.get_model(*model_identifier.split(".")) 
  • django/core/xheaders.py

    diff --git a/django/core/xheaders.py b/django/core/xheaders.py
    index b650a3a..3766628 100644
    a b def populate_xheaders(request, response, model, object_id): 
    2020    if (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS 
    2121            or (hasattr(request, 'user') and request.user.is_active 
    2222                and request.user.is_staff)): 
    23         response['X-Object-Type'] = "%s.%s" % (model._meta.app_label, model._meta.object_name.lower()) 
     23        response['X-Object-Type'] = "%s.%s" % (model._meta.app_label, model._meta.model_name) 
    2424        response['X-Object-Id'] = str(object_id) 
  • django/db/models/base.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    index 38afc60..5f05865 100644
    a b class ModelBase(type): 
    191191                if base in o2o_map: 
    192192                    field = o2o_map[base] 
    193193                elif not is_proxy: 
    194                     attr_name = '%s_ptr' % base._meta.module_name 
     194                    attr_name = '%s_ptr' % base._meta.model_name 
    195195                    field = OneToOneField(base, name=attr_name, 
    196196                            auto_created=True, parent_link=True) 
    197197                    new_class.add_to_class(attr_name, field) 
    def method_get_order(ordered_obj, self): 
    973973############################################## 
    974974 
    975975def get_absolute_url(opts, func, self, *args, **kwargs): 
    976     return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label, opts.module_name), func)(self, *args, **kwargs) 
     976    return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label, opts.model_name), func)(self, *args, **kwargs) 
    977977 
    978978 
    979979######## 
  • django/db/models/fields/related.py

    diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
    index ae792a3..bd2e288 100644
    a b class RelatedField(object): 
    118118            self.do_related_class(other, cls) 
    119119 
    120120    def set_attributes_from_rel(self): 
    121         self.name = self.name or (self.rel.to._meta.object_name.lower() + '_' + self.rel.to._meta.pk.name) 
     121        self.name = self.name or (self.rel.to._meta.model_name + '_' + self.rel.to._meta.pk.name) 
    122122        if self.verbose_name is None: 
    123123            self.verbose_name = self.rel.to._meta.verbose_name 
    124124        self.rel.field_name = self.rel.field_name or self.rel.to._meta.pk.name 
    class RelatedField(object): 
    222222        # related object in a table-spanning query. It uses the lower-cased 
    223223        # object_name by default, but this can be overridden with the 
    224224        # "related_name" option. 
    225         return self.rel.related_name or self.opts.object_name.lower() 
     225        return self.rel.related_name or self.opts.model_name 
    226226 
    227227 
    228228class SingleRelatedObjectDescriptor(object): 
    class ForeignKey(RelatedField, Field): 
    983983 
    984984    def __init__(self, to, to_field=None, rel_class=ManyToOneRel, **kwargs): 
    985985        try: 
    986             to_name = to._meta.object_name.lower() 
     986            to_name = to._meta.model_name 
    987987        except AttributeError:  # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT 
    988988            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) 
    989989        else: 
    def create_many_to_many_intermediary_model(field, klass): 
    11741174        from_ = 'from_%s' % to.lower() 
    11751175        to = 'to_%s' % to.lower() 
    11761176    else: 
    1177         from_ = klass._meta.object_name.lower() 
     1177        from_ = klass._meta.model_name 
    11781178        to = to.lower() 
    11791179    meta = type('Meta', (object,), { 
    11801180        'db_table': field._get_m2m_db_table(klass._meta), 
  • django/db/models/loading.py

    diff --git a/django/db/models/loading.py b/django/db/models/loading.py
    index 56edc36..c027105 100644
    a b class AppCache(object): 
    239239        for model in models: 
    240240            # Store as 'name: model' pair in a dictionary 
    241241            # in the app_models dictionary 
    242             model_name = model._meta.object_name.lower() 
     242            model_name = model._meta.model_name 
    243243            model_dict = self.app_models.setdefault(app_label, SortedDict()) 
    244244            if model_name in model_dict: 
    245245                # The same model may be imported via different paths (e.g. 
  • django/db/models/options.py

    diff --git a/django/db/models/options.py b/django/db/models/options.py
    index 952596b..a302e2d 100644
    a b from __future__ import unicode_literals 
    22 
    33import re 
    44from bisect import bisect 
     5import warnings 
    56 
    67from django.conf import settings 
    78from django.db.models.fields.related import ManyToManyRel 
    class Options(object): 
    2829    def __init__(self, meta, app_label=None): 
    2930        self.local_fields, self.local_many_to_many = [], [] 
    3031        self.virtual_fields = [] 
    31         self.module_name, self.verbose_name = None, None 
     32        self.model_name, self.verbose_name = None, None 
    3233        self.verbose_name_plural = None 
    3334        self.db_table = '' 
    3435        self.ordering = [] 
    class Options(object): 
    7879        self.installed = re.sub('\.models$', '', cls.__module__) in settings.INSTALLED_APPS 
    7980        # First, construct the default values for these options. 
    8081        self.object_name = cls.__name__ 
    81         self.module_name = self.object_name.lower() 
     82        self.model_name = self.object_name.lower() 
    8283        self.verbose_name = get_verbose_name(self.object_name) 
    8384 
    8485        # Next, apply any overridden values from 'class Meta'. 
    class Options(object): 
    116117            self.verbose_name_plural = string_concat(self.verbose_name, 's') 
    117118        del self.meta 
    118119 
    119         # If the db_table wasn't provided, use the app_label + module_name. 
     120        # If the db_table wasn't provided, use the app_label + model_name. 
    120121        if not self.db_table: 
    121             self.db_table = "%s_%s" % (self.app_label, self.module_name) 
     122            self.db_table = "%s_%s" % (self.app_label, self.model_name) 
    122123            self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) 
    123124 
     125    @property 
     126    def module_name(self): 
     127        """ 
     128        This property has been deprecated in favor of `model_name`. refs #19689 
     129        """ 
     130        warnings.warn( 
     131            "Options.module_name has been deprecated in favor of model_name", 
     132            PendingDeprecationWarning, stacklevel=2) 
     133        return self.model_name 
     134 
    124135    def _prepare(self, model): 
    125136        if self.order_with_respect_to: 
    126137            self.order_with_respect_to = self.get_field(self.order_with_respect_to) 
    class Options(object): 
    193204        return '<Options for %s>' % self.object_name 
    194205 
    195206    def __str__(self): 
    196         return "%s.%s" % (smart_text(self.app_label), smart_text(self.module_name)) 
     207        return "%s.%s" % (smart_text(self.app_label), smart_text(self.model_name)) 
    197208 
    198209    def verbose_name_raw(self): 
    199210        """ 
    class Options(object): 
    217228        case insensitive, so we make sure we are case insensitive here. 
    218229        """ 
    219230        if self.swappable: 
    220             model_label = '%s.%s' % (self.app_label, self.object_name.lower()) 
     231            model_label = '%s.%s' % (self.app_label, self.model_name) 
    221232            swapped_for = getattr(settings, self.swappable, None) 
    222233            if swapped_for: 
    223234                try: 
    class Options(object): 
    371382        return cache 
    372383 
    373384    def get_add_permission(self): 
    374         return 'add_%s' % self.object_name.lower() 
     385        return 'add_%s' % self.model_name 
    375386 
    376387    def get_change_permission(self): 
    377         return 'change_%s' % self.object_name.lower() 
     388        return 'change_%s' % self.model_name 
    378389 
    379390    def get_delete_permission(self): 
    380         return 'delete_%s' % self.object_name.lower() 
     391        return 'delete_%s' % self.model_name 
    381392 
    382393    def get_all_related_objects(self, local_only=False, include_hidden=False, 
    383394                                include_proxy_eq=False): 
  • django/db/models/related.py

    diff --git a/django/db/models/related.py b/django/db/models/related.py
    index 2693213..53645be 100644
    a b class RelatedObject(object): 
    1616        self.model = model 
    1717        self.opts = model._meta 
    1818        self.field = field 
    19         self.name = '%s:%s' % (self.opts.app_label, self.opts.module_name) 
    20         self.var_name = self.opts.object_name.lower() 
     19        self.name = '%s:%s' % (self.opts.app_label, self.opts.model_name) 
     20        self.var_name = self.opts.model_name 
    2121 
    2222    def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, 
    2323                    limit_to_currently_related=False): 
    class RelatedObject(object): 
    3131        queryset = self.model._default_manager.all() 
    3232        if limit_to_currently_related: 
    3333            queryset = queryset.complex_filter( 
    34                 {'%s__isnull' % self.parent_model._meta.module_name: False}) 
     34                {'%s__isnull' % self.parent_model._meta.model_name: False}) 
    3535        lst = [(x._get_pk_val(), smart_text(x)) for x in queryset] 
    3636        return first_choice + lst 
    3737 
    class RelatedObject(object): 
    5656            # If this is a symmetrical m2m relation on self, there is no reverse accessor. 
    5757            if getattr(self.field.rel, 'symmetrical', False) and self.model == self.parent_model: 
    5858                return None 
    59             return self.field.rel.related_name or (self.opts.object_name.lower() + '_set') 
     59            return self.field.rel.related_name or (self.opts.model_name + '_set') 
    6060        else: 
    61             return self.field.rel.related_name or (self.opts.object_name.lower()) 
     61            return self.field.rel.related_name or (self.opts.model_name) 
    6262 
    6363    def get_cache_name(self): 
    6464        return "_%s_cache" % self.get_accessor_name() 
  • django/views/generic/detail.py

    diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py
    index c27b92b..58302bb 100644
    a b class SingleObjectMixin(ContextMixin): 
    8484        if self.context_object_name: 
    8585            return self.context_object_name 
    8686        elif isinstance(obj, models.Model): 
    87             return obj._meta.object_name.lower() 
     87            return obj._meta.model_name 
    8888        else: 
    8989            return None 
    9090 
    class SingleObjectTemplateResponseMixin(TemplateResponseMixin): 
    144144        if isinstance(self.object, models.Model): 
    145145            names.append("%s/%s%s.html" % ( 
    146146                self.object._meta.app_label, 
    147                 self.object._meta.object_name.lower(), 
     147                self.object._meta.model_name, 
    148148                self.template_name_suffix 
    149149            )) 
    150150        elif hasattr(self, 'model') and self.model is not None and issubclass(self.model, models.Model): 
    151151            names.append("%s/%s%s.html" % ( 
    152152                self.model._meta.app_label, 
    153                 self.model._meta.object_name.lower(), 
     153                self.model._meta.model_name, 
    154154                self.template_name_suffix 
    155155            )) 
    156156        return names 
  • django/views/generic/list.py

    diff --git a/django/views/generic/list.py b/django/views/generic/list.py
    index 1f28616..08c4bbc 100644
    a b class MultipleObjectMixin(ContextMixin): 
    9797        if self.context_object_name: 
    9898            return self.context_object_name 
    9999        elif hasattr(object_list, 'model'): 
    100             return '%s_list' % object_list.model._meta.object_name.lower() 
     100            return '%s_list' % object_list.model._meta.model_name 
    101101        else: 
    102102            return None 
    103103 
    class MultipleObjectTemplateResponseMixin(TemplateResponseMixin): 
    177177        # generated ones. 
    178178        if hasattr(self.object_list, 'model'): 
    179179            opts = self.object_list.model._meta 
    180             names.append("%s/%s%s.html" % (opts.app_label, opts.object_name.lower(), self.template_name_suffix)) 
     180            names.append("%s/%s%s.html" % (opts.app_label, opts.model_name, self.template_name_suffix)) 
    181181 
    182182        return names 
    183183 
  • docs/internals/deprecation.txt

    diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
    index df3d84f..099951d 100644
    a b these changes. 
    327327  :class:`django.middleware.common.BrokenLinkEmailsMiddleware` middleware to 
    328328  your :setting:`MIDDLEWARE_CLASSES` setting instead. 
    329329 
     330* The undocumented ``module_name`` model meta attribute was renamed to 
     331  ``model_name`` in 1.6. The backward compatibility will be removed -- 
     332  ``Model._meta.module_name`` will no longer work. 
     333 
    3303342.0 
    331335--- 
    332336 
  • docs/releases/1.6.txt

    diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt
    index 32e5172..d5b0d4a 100644
    a b from your settings. 
    127127 
    128128If you defined your own form widgets and defined the ``_has_changed`` method 
    129129on a widget, you should now define this method on the form field itself. 
     130 
     131``module_name`` model meta attribute 
     132~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     133 
     134This undocumented and meaningless ``module_name`` attribute of 
     135``django.db.models.options.Options`` was renamed to ``model_name``. 
     136 No newline at end of file 
  • tests/regressiontests/admin_custom_urls/models.py

    diff --git a/tests/regressiontests/admin_custom_urls/models.py b/tests/regressiontests/admin_custom_urls/models.py
    index ef04c2a..55fc064 100644
    a b class ActionAdmin(admin.ModelAdmin): 
    4242                return self.admin_site.admin_view(view)(*args, **kwargs) 
    4343            return update_wrapper(wrapper, view) 
    4444 
    45         info = self.model._meta.app_label, self.model._meta.module_name 
     45        info = self.model._meta.app_label, self.model._meta.model_name 
    4646 
    4747        view_name = '%s_%s_add' % info 
    4848