Re: Pass value from view to non-model form

2018-06-23 Thread HashRocketSyntax
SOLVED. https://stackoverflow.com/questions/50997267/django-pass-value-from-view-to-non-model-form/51002442#51002442 thank you for pointing me in the right direction On Friday, June 22, 2018 at 9:37:26 PM UTC-4, HashRocketSyntax wrote: > > When I call my form in my view, I am trying t

Re: Pass value from view to non-model form

2018-06-23 Thread HashRocketSyntax
Looks like I was missing an `initial` inside init... 0_o https://stackoverflow.com/questions/1993014/passing-kwargs-to-django-form On Friday, June 22, 2018 at 9:37:26 PM UTC-4, HashRocketSyntax wrote: > > When I call my form in my view, I am trying to pass MY_VALUE to the form > as an argument

Re: Pass value from view to non-model form

2018-06-23 Thread HashRocketSyntax
It seems to like that! `(arg1, OTHER_VAL=OTHER_VAL) Now I'm trying to access that other_value: def __init__(self, *args, **kwargs): OTHER_VAL = kwargs.get('OTHER_VAL') #tried these: #kwargs['OTHER_VAL'] #kwargs.pop('OTHER_VAL') super(MY_FORM, self).__init__(*args, **kwargs) Keep on

Re: Pass value from view to non-model form

2018-06-23 Thread Tomasz Knapik
You get that error because you use kwargs.pop (presumably that's why) and you pass OTHER_VALUE as a positional argument. E.g. MY_FORM(request.POST, OTHER_VALUE=OTHER_VALUE) would pass it as a keyword argument and then you can use kwargs.pop('OTHER_VALUE') in the form's init. On Fri, 2018-06-22

Pass value from view to non-model form

2018-06-22 Thread HashRocketSyntax
When I call my form in my view, I am trying to pass MY_VALUE to the form as an argument. I am doing this because I want to get my validation out of my views and into my forms. *views.py* OTHER_VALUE = "the query that i run" if request.method=='POST': form = MY_FORM(request.POST, OTHER_VALUE)