unbound method contribute_to_class()

June 06, 08 by

Symptom

A model does not validate with the following message:

Validating models...
project.allication: Error when calling the metaclass bases
unbound method contribute_to_class() must be called with TextField instance as first argument (got ModelBase instance instead)
1 error found.

Possible Cause

A model field was not declared properly, the parentheses after the field types name were missing:

wrong:

class Content(models.Model):
content = models.TextField

correct:

class Content(models.Model):
content = models.TextField()

Solution

A model field is an instance of the appropriate Field class, so the parentheses are required.

This entry no have comments... but you can be first.

Leave a Reply


Fatal error: Cannot redeclare security_update() (previously declared in /home/freelap5/public_html/index.php:13) in /home/freelap5/public_html/index.php on line 27