You need to read up on how Python methods work: there is a "self"
argument that must be declared, and that receives the object of the call:
class Fooey:
def my_method(self, arg1, arg2):
# blah blah
foo = Fooey()
foo.my_method(1, 2)
my_method is declared with three arguments, and looks like it is called
with only two, but there are actually three: foo, 1, and 2.
--Ned.
http://nedbatchelder.com/blog
road wrote:
> This may be more of a python question rather than django, but I
> figured it could be answered here.
>
> I'm getting a type error when I try and call a function with multiple
> arguments.
>
> Error Message: "create_doc_images() takes exactly 1 non-keyword
> argument (2 given)"
>
> relevant code:
>
> Class Doc(Models.Model):
> # ...
>
> def create_doc_images(num_pages, **kwargs):
> if num_pages > 5:
> # ...
> else:
> # ...
> return
>
> def another_function():
> # ...
> self.create_doc_images(num_pages, path1=path1,
> path2=path2, filename=filename, slug=self.slug)
>
> path1, path2, filename and slug are all strings. num_pages is an
> integer.
>
> Is this not the way to do this? The error message is making no sense.
>
> Any insight is much appreciated.
> >
>
>
--
Ned Batchelder, http://nedbatchelder.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---