magic-removal: Renamed 'class META' to 'class Meta' in models
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1754 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fe524625ed
commit
29fe9598e0
|
@ -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'
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',)
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
-------------
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue