Opened 19 years ago

Closed 19 years ago

#1150 closed defect (invalid)

The custom method does not work

Reported by: anonymous Owned by: Adrian Holovaty
Component: Core (Other) Version: 0.90
Severity: major Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

from django.core import meta
class Tescik(meta.Model):

... name = meta.CharField(maxlength=255)
... order = meta.IntegerField(null=True)
... def hello(self):
... return "Hello WORLD!"
...

from django.models.biblia import tesciks
print dir(tesciks)

['AddManipulator', 'ChangeManipulator', 'Klass', 'Tescik', 'TescikDoesNotExist', 'doc', 'file', 'name', '_get_sql_clause', 'get_count', 'get_in_bulk', 'get_iterator', 'get_list', 'get_object', 'get_values', 'get_values_iterator']

tesciks.hello

Traceback (most recent call last):

File "<interactive input>", line 1, in ?

AttributeError: 'module' object has no attribute 'hello'

Attachments (1)

code.py (690 bytes ) - added by anonymous 19 years ago.

Download all attachments as: .zip

Change History (2)

by anonymous, 19 years ago

Attachment: code.py added

comment:1 by Adrian Holovaty, 19 years ago

Resolution: invalid
Status: newclosed

There's a distinction between "module-level" methods and "class-level" methods. See http://www.djangoproject.com/documentation/model_api/#module-level-methods

Note: See TracTickets for help on using tickets.
Back to Top