Code

Opened 8 years ago

Closed 8 years ago

#1150 closed defect (invalid)

The custom method does not work

Reported by: anonymous Owned by: adrian
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: UI/UX:

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 8 years ago.

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by anonymous

comment:1 Changed 8 years ago by adrian

  • Resolution set to invalid
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.