Extending on Tadeck's Django answer above, the use of 'class Meta:' in Django is just normal Python too.
The internal class is a convenient namespace for shared data among the class instances (hence the name Meta for 'metadata' but you can call it anything you like). While in Django it's generally read-only configuration stuff, there is nothing to stop you changing it:
In [1]: class Foo(object):
...: class Meta:
...: metaVal = 1
...:
In [2]: f1 = Foo()
In [3]: f2 = Foo()
In [4]: f1.Meta.metaVal
Out[4]: 1
In [5]: f2.Meta.metaVal = 2
In [6]: f1.Meta.metaVal
Out[6]: 2
In [7]: Foo.Meta.metaVal
Out[7]: 2
You can explore it in Django directly too e.g:
In [1]: from django.contrib.auth.models import User
In [2]: User.Meta
Out[2]: django.contrib.auth.models.Meta
In [3]: User.Meta.__dict__
Out[3]:
{'__doc__': None,
'__module__': 'django.contrib.auth.models',
'abstract': False,
'verbose_name': <django.utils.functional.__proxy__ at 0x26a6610>,
'verbose_name_plural': <django.utils.functional.__proxy__ at 0x26a6650>}
However, in Django you are more likely to want to explore the _meta
attribute which is an Options
object created by the model metaclass
when a model is created. That is where you'll find all of the Django class 'meta' information. In Django, Meta
is just used to pass information into the process of creating the _meta
Options
object.