1809.1.1
by jtv at canonical
Update copyright dates on template files. Annual chore. |
1 |
# Copyright 2014 Canonical Ltd. This software is licensed under the
|
496.1.2
by Jeroen Vermeulen
Template for adding a new model module. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
3 |
||
4 |
# TODO: Module docstring.
|
|
5 |
"""..."""
|
|
6 |
||
7 |
from __future__ import ( |
|
8 |
absolute_import, |
|
9 |
print_function, |
|
10 |
unicode_literals, |
|
11 |
)
|
|
12 |
||
1640.1.9
by Gavin Panella
Alias str to None instead of unicode. |
13 |
str = None |
1640.1.1
by Gavin Panella
Alias str to unicode everywhere. |
14 |
|
496.1.2
by Jeroen Vermeulen
Template for adding a new model module. |
15 |
__metaclass__ = type |
16 |
__all__ = [ |
|
1640.1.1
by Gavin Panella
Alias str to unicode everywhere. |
17 |
# TODO: Your class name here.
|
496.1.2
by Jeroen Vermeulen
Template for adding a new model module. |
18 |
'ModelClass', |
19 |
]
|
|
20 |
||
21 |
||
547.1.2
by Jeroen Vermeulen
Import individual items from django.db.models. |
22 |
from django.db.models import ( |
23 |
Manager, |
|
24 |
Model, |
|
25 |
)
|
|
1875.1.1
by jtv at canonical
Register Django models from admin.py, not models/__init__.py. |
26 |
# TODO: Import the DefaultMeta from the appropriate app, e.g. metadataserver.
|
496.1.2
by Jeroen Vermeulen
Template for adding a new model module. |
27 |
from maasserver import DefaultMeta |
28 |
||
29 |
||
547.1.2
by Jeroen Vermeulen
Import individual items from django.db.models. |
30 |
class ModelManager(Manager): |
496.1.2
by Jeroen Vermeulen
Template for adding a new model module. |
31 |
"""Manager for model class.
|
32 |
||
33 |
Don't import or instantiate this directly; access as `<Class>.objects` on
|
|
34 |
the model class it manages.
|
|
35 |
"""
|
|
36 |
||
1875.1.3
by jtv at canonical
Turns out we don't need to list models for registration in the admin site. Django can do that for us. |
37 |
# TODO: Import your model into, and export it from, models/__init__.py
|
1875.1.1
by jtv at canonical
Register Django models from admin.py, not models/__init__.py. |
38 |
|
496.1.2
by Jeroen Vermeulen
Template for adding a new model module. |
39 |
|
40 |
# TODO: Your class name here.
|
|
547.1.2
by Jeroen Vermeulen
Import individual items from django.db.models. |
41 |
class ModelClass(Model): |
496.1.2
by Jeroen Vermeulen
Template for adding a new model module. |
42 |
|
43 |
class Meta(DefaultMeta): |
|
44 |
"""Needed for South to recognize this model."""
|
|
45 |
||
46 |
objects = ModelManager() |