I’m having a problem while trying to call a custom Model method from my Form clean method.
Here is [part of] my model:
http://dpaste.com/hold/12695/
Here is my Form:
http://dpaste.com/hold/12699/
I’m specifically having a problem with line 11 in my Form:
nzb_data = File.get_nzb_data(nzb_absolute)
This raises the following error:
TypeError at /admin/main/file/add/ unbound method get_nzb_data() must be called with File instance as first argument (got str instance instead)
By this error I can assume I have to pass the method something (a File instance), however I don’t really know what that means and how I can do it.
Can you let me know what I’m doing wrong here, and what can be done to resolve the issue?
Solved by making the get_nzb_data method a class method using the @classmethod decorator.
You can’t call
because your using the class, not an object.
You have two choices.
Make
get_nzb_dataa@classmethod. See http://docs.python.org/library/functions.html#classmethodCreate an instance of File and use that.
temp_f= File(...). Thentemp_f.get_dnb_data.