diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index 3bcbf483ec..3163ae5204 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -20,7 +20,7 @@ class LogEntry(models.Model): action_flag = models.PositiveSmallIntegerField(_('action flag')) change_message = models.TextField(_('change message'), blank=True) objects = LogEntryManager() - class META: + class Meta: verbose_name = _('log entry') verbose_name_plural = _('log entries') db_table = 'django_admin_log' diff --git a/django/contrib/comments/models.py b/django/contrib/comments/models.py index 582a897a93..b1034cc4ea 100644 --- a/django/contrib/comments/models.py +++ b/django/contrib/comments/models.py @@ -84,7 +84,7 @@ class Comment(models.Model): is_removed = models.BooleanField(_('is removed'), help_text=_('Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.')) site = models.ForeignKey(core.Site) objects = CommentManager() - class META: + class Meta: db_table = 'comments' verbose_name = _('Comment') verbose_name_plural = _('Comments') @@ -172,7 +172,7 @@ class FreeComment(models.Model): # TODO: Change this to is_removed, like Comment approved = models.BooleanField(_('approved by staff')) site = models.ForeignKey(core.Site) - class META: + class Meta: db_table = 'comments_free' verbose_name = _('Free comment') verbose_name_plural = _('Free comments') @@ -235,7 +235,7 @@ class KarmaScore(models.Model): score = models.SmallIntegerField(_('score'), db_index=True) scored_date = models.DateTimeField(_('score date'), auto_now=True) objects = KarmaScoreManager() - class META: + class Meta: verbose_name = _('Karma score') verbose_name_plural = _('Karma scores') unique_together = (('user', 'comment'),) @@ -266,7 +266,7 @@ class UserFlag(models.Model): comment = models.ForeignKey(Comment) flag_date = models.DateTimeField(_('flag date'), auto_now_add=True) objects = UserFlagManager() - class META: + class Meta: db_table = 'comments_user_flags' verbose_name = _('User flag') verbose_name_plural = _('User flags') @@ -279,7 +279,7 @@ class ModeratorDeletion(models.Model): user = models.ForeignKey(auth.User, verbose_name='moderator') comment = models.ForeignKey(Comment) deletion_date = models.DateTimeField(_('deletion date'), auto_now_add=True) - class META: + class Meta: db_table = 'comments_moderator_deletions' verbose_name = _('Moderator deletion') verbose_name_plural = _('Moderator deletions') diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py index a942542292..18599f8ea1 100644 --- a/django/contrib/flatpages/models.py +++ b/django/contrib/flatpages/models.py @@ -13,7 +13,7 @@ class FlatPage(models.Model): help_text=_("Example: 'flatpages/contact_page'. If this isn't provided, the system will use 'flatpages/default'.")) registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page.")) sites = models.ManyToManyField(Site) - class META: + class Meta: db_table = 'django_flatpages' verbose_name = _('flat page') verbose_name_plural = _('flat pages') diff --git a/django/contrib/redirects/models.py b/django/contrib/redirects/models.py index b653e36002..98d03a9ade 100644 --- a/django/contrib/redirects/models.py +++ b/django/contrib/redirects/models.py @@ -8,7 +8,7 @@ class Redirect(models.Model): help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'.")) new_path = models.CharField(_('redirect to'), maxlength=200, blank=True, help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'.")) - class META: + class Meta: verbose_name = _('redirect') verbose_name_plural = _('redirects') db_table = 'django_redirects' diff --git a/django/core/management.py b/django/core/management.py index f86660cccf..b5ed60d2c5 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -699,7 +699,7 @@ def inspectdb(db_name): if field_type_was_guessed: field_desc += ' # This is a guess!' yield ' %s' % field_desc - yield ' class META:' + yield ' class Meta:' yield ' db_table = %r' % table_name yield '' inspectdb.help_doc = "Introspects the database tables in the given database and outputs a Django model module." diff --git a/django/db/models/base.py b/django/db/models/base.py index 1b26afa7f3..d6c61b5129 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -30,7 +30,7 @@ class ModelBase(type): # Create the class. new_class = type.__new__(cls, name, bases, {'__module__': attrs.pop('__module__')}) - new_class.add_to_class('_meta', Options(attrs.pop('META', None))) + new_class.add_to_class('_meta', Options(attrs.pop('Meta', None))) new_class.add_to_class('DoesNotExist', types.ClassType('DoesNotExist', (ObjectDoesNotExist,), {})) #Figure out the app_label by looking one level up. diff --git a/django/db/models/options.py b/django/db/models/options.py index dfe54de00c..4f3b3e4e8b 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -33,7 +33,7 @@ class Options: self.order_with_respect_to = None self.module_constants = {} self.admin = None - + self.meta = meta self.pk = None self.has_auto_field = False @@ -46,7 +46,7 @@ class Options: for attr_name in DEFAULT_NAMES: setattr(self, attr_name, meta_attrs.pop(attr_name, getattr(self, attr_name))) if meta_attrs != {}: - raise TypeError, "'class META' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) + raise TypeError, "'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) def contribute_to_class(self, cls, name): cls._meta = self diff --git a/django/models/auth.py b/django/models/auth.py index 14974c97d4..6bd234d975 100644 --- a/django/models/auth.py +++ b/django/models/auth.py @@ -10,7 +10,7 @@ class Permission(models.Model): name = models.CharField(_('name'), maxlength=50) package = models.ForeignKey(core.Package, db_column='package') codename = models.CharField(_('codename'), maxlength=100) - class META: + class Meta: verbose_name = _('Permission') verbose_name_plural = _('Permissions') unique_together = (('package', 'codename'),) @@ -22,7 +22,7 @@ class Permission(models.Model): class Group(models.Model): name = models.CharField(_('name'), maxlength=80, unique=True) permissions = models.ManyToManyField(Permission, blank=True, filter_interface=models.HORIZONTAL) - class META: + class Meta: verbose_name = _('Group') verbose_name_plural = _('Groups') ordering = ('name',) @@ -64,7 +64,7 @@ class User(models.Model): help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in.")) user_permissions = models.ManyToManyField(Permission, blank=True, filter_interface=models.HORIZONTAL) objects = UserManager() - class META: + class Meta: verbose_name = _('User') verbose_name_plural = _('Users') ordering = ('username',) diff --git a/django/models/core.py b/django/models/core.py index 99c617065e..7112f1d9a5 100644 --- a/django/models/core.py +++ b/django/models/core.py @@ -12,7 +12,7 @@ class Site(models.Model): domain = models.CharField(_('domain name'), maxlength=100) name = models.CharField(_('display name'), maxlength=50) objects = SiteManager() - class META: + class Meta: verbose_name = _('site') verbose_name_plural = _('sites') db_table = 'sites' @@ -28,7 +28,7 @@ class Site(models.Model): class Package(models.Model): label = models.CharField(_('label'), maxlength=20, primary_key=True) name = models.CharField(_('name'), maxlength=30, unique=True) - class META: + class Meta: verbose_name = _('package') verbose_name_plural = _('packages') db_table = 'packages' @@ -41,7 +41,7 @@ class ContentType(models.Model): name = models.CharField(_('name'), maxlength=100) package = models.ForeignKey(Package, db_column='package') python_module_name = models.CharField(_('python module name'), maxlength=50) - class META: + class Meta: verbose_name = _('content type') verbose_name_plural = _('content types') db_table = 'content_types' @@ -98,7 +98,7 @@ class Session(models.Model): session_data = models.TextField(_('session data')) expire_date = models.DateTimeField(_('expire date')) objects = SessionManager() - class META: + class Meta: verbose_name = _('session') verbose_name_plural = _('sessions') module_constants = { diff --git a/docs/authentication.txt b/docs/authentication.txt index d31e2ced79..c5d9ceda7e 100644 --- a/docs/authentication.txt +++ b/docs/authentication.txt @@ -395,20 +395,20 @@ Custom permissions ------------------ To create custom permissions for a given model object, use the ``permissions`` -`model META attribute`_. +`model Meta attribute`_. This example model creates three custom permissions:: class USCitizen(meta.Model): # ... - class META: + class Meta: permissions = ( ("can_drive", "Can drive"), ("can_vote", "Can vote in elections"), ("can_drink", "Can drink alcohol"), ) -.. _model META attribute: http://www.djangoproject.com/documentation/model_api/#meta-options +.. _model Meta attribute: http://www.djangoproject.com/documentation/model_api/#meta-options API reference ------------- diff --git a/docs/forms.txt b/docs/forms.txt index 6074564ce9..2980ce80e1 100644 --- a/docs/forms.txt +++ b/docs/forms.txt @@ -32,7 +32,7 @@ this document, we'll be working with the following model, a "place" object:: state = meta.USStateField(), zip_code = meta.CharField(maxlength=5, blank=True), place_type = meta.IntegerField(choices=PLACE_TYPES) - class META: + class Meta: admin = meta.Admin() def __repr__(self): diff --git a/docs/i18n.txt b/docs/i18n.txt index a02841f28f..acfefef042 100644 --- a/docs/i18n.txt +++ b/docs/i18n.txt @@ -150,14 +150,14 @@ If you don't like the verbose name ``gettext_lazy``, you can just alias it as Always use lazy translations in `Django models`_. And it's a good idea to add translations for the field names and table names, too. This means writing -explicit ``verbose_name`` and ``verbose_name_plural`` options in the ``META`` +explicit ``verbose_name`` and ``verbose_name_plural`` options in the ``Meta`` class, though:: from django.utils.translation import gettext_lazy as _ class MyThing(meta.Model): name = meta.CharField(_('name'), help_text=_('This is the help text')) - class META: + class Meta: verbose_name = _('my thing') verbose_name_plural = _('mythings') diff --git a/docs/model-api.txt b/docs/model-api.txt index a6e5adf917..3644d9de87 100644 --- a/docs/model-api.txt +++ b/docs/model-api.txt @@ -10,7 +10,7 @@ The basics: * Each model is a Python class that subclasses ``django.core.meta.Model``. * Each attribute of the model represents a database field. - * Model metadata (non-field information) goes in an inner class named ``META``. + * Model metadata (non-field information) goes in an inner class named ``Meta``. A companion to this document is the `official repository of model examples`_. @@ -21,7 +21,7 @@ Field objects The most important part of a model is the list of database fields it defines. Fields are defined by class attributes. Each class attribute in a model, aside -from the optional inner ``class META``, should be an instance of a +from the optional inner ``class Meta``, should be an instance of a ``meta.Field`` subclass. In this example, there are two fields, ``first_name`` and ``last_name`` :: @@ -700,23 +700,23 @@ See the `One-to-one relationship model example`_ for a full example. .. _One-to-one relationship model example: http://www.djangoproject.com/documentation/models/one_to_one/ -META options +Meta options ============ -Give your model metadata by using an inner ``"class META"``, like so:: +Give your model metadata by using an inner ``"class Meta"``, like so:: class Foo(meta.Model): bar = meta.CharField(maxlength=30) # ... - class META: + class Meta: admin = meta.Admin() # ... Model metadata is "anything that's not a field" -- ordering options, admin options, etc. -Here's a list of all possible ``META`` options. No options are required. Adding -``class META`` to a model is completely optional. +Here's a list of all possible ``Meta`` options. No options are required. Adding +``class Meta`` to a model is completely optional. ``admin`` A ``meta.Admin`` object; see `Admin options`_. If this field is given, the @@ -943,7 +943,7 @@ object, which takes the following parameters. All are optional. if one of the ``list_display`` fields is a ``ForeignKey``. ``ordering`` - A list or tuple (see the `META options`_, above) that gives a + A list or tuple (see the `Meta options`_, above) that gives a different ordering for the admin change list. If this isn't given, the model's default ordering will be used. diff --git a/docs/overview.txt b/docs/overview.txt index 11fa7d1fa9..96c48f32c8 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -138,7 +138,7 @@ model classes:: headline = meta.CharField(maxlength=200) article = meta.TextField() reporter = meta.ForeignKey(Reporter) - class META: + class Meta: admin = meta.Admin() The philosophy here is that your site is edited by a staff, or a client, or diff --git a/docs/tutorial02.txt b/docs/tutorial02.txt index 0f1792bc62..21454523d0 100644 --- a/docs/tutorial02.txt +++ b/docs/tutorial02.txt @@ -93,15 +93,15 @@ But where's our poll app? It's not displayed on the admin index page. Just one thing to do: We need to specify in the ``polls.Poll`` model that Poll objects have an admin interface. Edit the ``myproject/apps/polls/models/polls.py`` -file and make the following change to add an inner ``META`` class with an +file and make the following change to add an inner ``Meta`` class with an ``admin`` attribute:: class Poll(meta.Model): # ... - class META: + class Meta: admin = meta.Admin() -The ``class META`` contains all non-field metadata about this model. +The ``class Meta`` contains all non-field metadata about this model. Now reload the Django admin page to see your changes. Note that you don't have to restart the development server -- it auto-reloads code. @@ -227,7 +227,7 @@ Here's what that would look like:: class Choice(meta.Model): # ... - class META: + class Meta: admin = meta.Admin() Now "Choices" is an available option in the Django admin. The "Add choice" form @@ -311,7 +311,7 @@ on the change list page for the object:: class Poll(meta.Model): # ... - class META: + class Meta: admin = meta.Admin( # ... list_display = ('question', 'pub_date'), diff --git a/tests/modeltests/custom_pk/models.py b/tests/modeltests/custom_pk/models.py index 4432feec08..aec17ff055 100644 --- a/tests/modeltests/custom_pk/models.py +++ b/tests/modeltests/custom_pk/models.py @@ -11,7 +11,7 @@ class Employee(models.Model): employee_code = models.CharField(maxlength=10, primary_key=True) first_name = models.CharField(maxlength=20) last_name = models.CharField(maxlength=20) - class META: + class Meta: ordering = ('last_name', 'first_name') def __repr__(self): @@ -20,7 +20,7 @@ class Employee(models.Model): class Business(models.Model): name = models.CharField(maxlength=20, primary_key=True) employees = models.ManyToManyField(Employee) - class META: + class Meta: verbose_name_plural = 'businesses' module_name = 'businesses' diff --git a/tests/modeltests/get_latest/models.py b/tests/modeltests/get_latest/models.py index 087814d573..810ba9bbf7 100644 --- a/tests/modeltests/get_latest/models.py +++ b/tests/modeltests/get_latest/models.py @@ -13,7 +13,7 @@ from django.db import models class Article(models.Model): headline = models.CharField(maxlength=100) pub_date = models.DateTimeField() - class META: + class Meta: get_latest_by = 'pub_date' def __repr__(self): diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py index 12818b5eb7..599cff44d0 100644 --- a/tests/modeltests/lookup/models.py +++ b/tests/modeltests/lookup/models.py @@ -9,7 +9,7 @@ from django.db import models class Article(models.Model): headline = models.CharField(maxlength=100) pub_date = models.DateTimeField() - class META: + class Meta: ordering = ('-pub_date', 'headline') def __repr__(self): diff --git a/tests/modeltests/m2m_multiple/models.py b/tests/modeltests/m2m_multiple/models.py index 0c36e3a5e9..aac188d83e 100644 --- a/tests/modeltests/m2m_multiple/models.py +++ b/tests/modeltests/m2m_multiple/models.py @@ -14,7 +14,7 @@ from django.db import models class Category(models.Model): name = models.CharField(maxlength=20) - class META: + class Meta: ordering = ('name',) def __repr__(self): @@ -27,7 +27,7 @@ class Article(models.Model): singular='primary_category', related_name='primary_article') secondary_categories = models.ManyToManyField(Category, singular='secondary_category', related_name='secondary_article') - class META: + class Meta: ordering = ('pub_date',) def __repr__(self): diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py index af062b5af8..0a5fb541be 100644 --- a/tests/modeltests/or_lookups/models.py +++ b/tests/modeltests/or_lookups/models.py @@ -11,7 +11,7 @@ from django.db import models class Article(models.Model): headline = models.CharField(maxlength=50) pub_date = models.DateTimeField() - class META: + class Meta: ordering = ('pub_date',) def __repr__(self): diff --git a/tests/modeltests/ordering/models.py b/tests/modeltests/ordering/models.py index 5dce89aa83..52a528b91b 100644 --- a/tests/modeltests/ordering/models.py +++ b/tests/modeltests/ordering/models.py @@ -18,7 +18,7 @@ from django.db import models class Article(models.Model): headline = models.CharField(maxlength=100) pub_date = models.DateTimeField() - class META: + class Meta: ordering = ('-pub_date', 'headline') def __repr__(self): diff --git a/tests/modeltests/reserved_names/models.py b/tests/modeltests/reserved_names/models.py index 7304f73765..e2cb4a7e31 100644 --- a/tests/modeltests/reserved_names/models.py +++ b/tests/modeltests/reserved_names/models.py @@ -18,7 +18,7 @@ class Thing(models.Model): having = models.CharField(maxlength=1) where = models.CharField(maxlength=1) has_hyphen = models.CharField(maxlength=1, db_column='has-hyphen') - class META: + class Meta: db_table = 'select' def __repr__(self):