It should be:
model.method1(**params)
On Apr 16, 2013 7:49 PM, "jayhalleaux" <jay.halle...@gmail.com> wrote:

> Not really a Django question but I'm trying to create a model method that
> does not have a fixed set of parameters.
>
> models.py
> Class Model_A(model.Model):
> ...
>
> def method1(self, **kwargs):
>
> print param1, param2, param3
>
>
>
> views.py
> params = dict(
>
> param1=something1,
> param2=something2,
> param3=something3,
> ...
>
> )
>
> model.method1(params)
>
> In this example when I try to do something like this it states that I
> should have passed only 1 parameter instead of 2.
>
> I thought the whole point of using '**' to unpack dictionaries is so you
> don't have to have a fixed number of parameters.
>
> Is there something I am missing or am I doing this incorrect? First time
> I'm trying to create a method like this.  Normally I explicitly state all
> parameters.
>
> Any help is appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to